Renaming files in a folder in bulk

1 回表示 (過去 30 日間)
BobbyRoberts
BobbyRoberts 2020 年 7 月 22 日
コメント済み: BobbyRoberts 2020 年 7 月 22 日
Hi. I am trying to rename a bunch of MAT files within a folder.
For example, the current files are named: AB007_group2_subject011_naive_day2_rawdata.mat
Each file varies on the numbers after "subject", "group, and "day".
I would like to change all of the files to be in the following format: AB007_subject011_day2_rawdata.mat
So essentially, I just want to delete the group and naive portion of the filename.
Thanks a lot!

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 7 月 22 日
編集済み: Fangjun Jiang 2020 年 7 月 22 日
>> name='AB007_group2_subject011_naive_day2_rawdata.mat'
name =
'AB007_group2_subject011_naive_day2_rawdata.mat'
>> name=regexprep(name,'_group\d+','')
name =
'AB007_subject011_naive_day2_rawdata.mat'
>> name=regexprep(name,'_naive','')
name =
'AB007_subject011_day2_rawdata.mat'
  3 件のコメント
Fangjun Jiang
Fangjun Jiang 2020 年 7 月 22 日
movefile(OldFileName,NewFileName)
BobbyRoberts
BobbyRoberts 2020 年 7 月 22 日
That's it! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by