画像ファイルに番号を順番につけたい。
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
HIGUCHI 樋口
am 23 Okt. 2022
Kommentiert: HIGUCHI 樋口
am 24 Nov. 2022
上図のように、あるフォルダーの中に適当な名前がついている画像ファイルがたくさんあります。
これを下図のように、順番に1番から連番で番号付けをしたいと考えています。更に、その連番になった画像ファイルを別フォルダーに保存したいと考えています。(ちなみにjpgファイルです)
(1番から順に連番になっていれば、上図と下図の画像ファイルの順番がバラバラでも問題ありません)
ご教示いただけると幸いです。宜しくお願い致します。
0 Kommentare
Akzeptierte Antwort
Atsushi Ueno
am 23 Okt. 2022
impath = uigetdir(pwd); % 画像が含まれるフォルダを選択する
imds = imageDatastore(impath); % イメージデータストア作成
imds.writeall(impath) % 選択フォルダ内にバックアップを作成しておく
for k = 1:length(imds.Files)
[path, name, ext] = fileparts(imds.Files{k}); % パス、ファイル名、拡張子を取得
movefile(imds.Files{k}, [path filesep num2str(k) ext]); % ファイル名を変更する
end
imformats
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!