필터 지우기
필터 지우기

Renaming files in a folder in bulk

조회 수: 6 (최근 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 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