ファイル名の変更
조회 수: 35 (최근 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!