rename files from subfolders
1 回表示 (過去 30 日間)
古いコメントを表示
Balaji M. Sontakke
2020 年 2 月 14 日
コメント済み: Balaji M. Sontakke
2020 年 2 月 14 日
I have a folder that contain 10 subfolders each subfolder contains 4 images named 1.bmp,2.bmp,3.bmp,4.bmp, I want to rename those images to 9.bmp,10.bmp,11.bmp,12.bmp like that how i can?
0 件のコメント
採用された回答
Bhaskar R
2020 年 2 月 14 日
Get all files structure to one variable
cd <your directory>
d = dir('**/*.bmp')
Apply loop to get every file to structure
filename_full = fullfile(d(loop variable).folder, d(loop variable).name);
[~, filename, ext] = fileparts(filename_full);
check file names use ifelse condition
if strcmp(filename, '1');
filename = '9' % so to all other 3 files
end
concatanate all string to form renamed path
filename_full_ren = fullfile(d(loop variable).folder,[filename, ext]);
then rename file by moving
movefile(filename_full, filename_full_ren);
You are done
5 件のコメント
Bhaskar R
2020 年 2 月 14 日
for ii = 1:4 % you have written for 4 files i think change for loop count as
end
for ii = 1:length(d) % change to this
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!