画像ファイルに番号を順番につけたい。
6 views (last 30 days)
Show older comments
上図のように、あるフォルダーの中に適当な名前がついている画像ファイルがたくさんあります。
これを下図のように、順番に1番から連番で番号付けをしたいと考えています。更に、その連番になった画像ファイルを別フォルダーに保存したいと考えています。(ちなみにjpgファイルです)
(1番から順に連番になっていれば、上図と下図の画像ファイルの順番がバラバラでも問題ありません)
ご教示いただけると幸いです。宜しくお願い致します。
0 Comments
Accepted Answer
Atsushi Ueno
on 23 Oct 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
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!