Renaming files in a folder in bulk

2 次查看(过去 30 天)
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)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by