ファイル名の変更
36 ビュー (過去 30 日間)
古いコメントを表示
動画ファイルのフレームのスタックを,7.5 frame/sec で,別ソフトで作成しました.そのスタックを保存する際に,各々のフレーム (tif形式で保存)のファイル名が,以下のようになりました.
0.13 s.tif, 0.27 s.tif, 0.40 s.tif, 0.53 s.tif, 0.67 s.tif, 0.80 s.tif, 0.93 s.tif, 1.07 s.tif, 1.20 s.tif, 1.33 s.tif
このファイル名を,
1.tif, 2.tif, 3.tif, 4.tif, 5.tif, 6.tif, 7.tif, 8.tif, 9.tif, 10.tif
のように,番号順のファイル名にしたいのですが,どのようにすればよろしいでしょうか.
0 件のコメント
採用された回答
Hernia Baby
2021 年 4 月 18 日
カレントディレクトリにそのファイル群があるという前提で行います。
% ~.tifの名前を抽出
tmp = dir('*.tif');
fname = {tmp.name};
% ~.tifの数だけ新しい名前を生成
cnt = 1;
while cnt <= length(fname)
nfname{cnt} = sprintf('%i.tif',cnt);
cnt = cnt+1;
end
% 名前の書き換え
for k=1:length(fname)
movefile(fname{k}, nfname{k});
end
自分のmファイルでは確認済です。
ちなみにこの方のコードを参照しました。
2 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!