Renames a lot of files in directory
2 次查看(过去 30 天)
显示 更早的评论
Hello, I have a lot of .mat files in a folder and I want to rename it from ex : 65300106179 into something like Flight 10001 and so on. Below is my code
f = dir( fullfile( projectdir, '**', '*.mat') );
for kk = 1:numel(f)
fileFrom = f(kk).name;
fileTo = ['Flight',erase(f(kk).name,'1000%d.mat'),'.mat'];
movefile(fileFrom,fileTo);
end
The problem I have is the file name changed into Flight65300106179.mat. Any idea where I did wrong?
0 个评论
采纳的回答
KSSV
2020-3-3
f = dir( fullfile( projectdir, '**', '*.mat') );
for kk = 1:numel(f)
fileFrom = f(kk).name;
fileTo = ['Flight','1000%d.mat','.mat'];
movefile(fileFrom,fileTo);
end
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!