How to rename a lot of files

2 ビュー (過去 30 日間)
Kadek Palgunadi
Kadek Palgunadi 2016 年 11 月 28 日
編集済み: KSSV 2016 年 11 月 28 日
i have file with name 001ab.SAC, 002ab.SAC.... 100ab.SAC and try to add character such as md05 so it will be like 001ab_md05.SAC, 002ab_md05.SAC.... 100ab_md05.SAC.
i am confuse to convert cell (001ab, 002ab... 100ab) to string, can anyone help me? Thankyou

回答 (1 件)

KSSV
KSSV 2016 年 11 月 28 日
編集済み: KSSV 2016 年 11 月 28 日
files = dir('*.SAC');
% Loop through each file
for id = 1:length(files)
% Get the file name (minus the extension)
[~, f] = fileparts(files(id).name);
% write the rename file
rf = strcat(f,'b_md05.SAC') ;
% rename the file
movefile(files(id).name, rf);
end

カテゴリ

Help Center および File ExchangeStandard File Formats についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by