rename files in a directory

조회 수: 4 (최근 30일)
sarah Abdellahi
sarah Abdellahi 2018년 11월 2일
편집: awezmm 2018년 11월 2일
Hello :)
I have several folders in a directory and in each folder there is a file named as DATA.mat. I want the code to open each folder, takes the DATA file and renames it as DATA_1 and pastes it in a new directory. Then Goes to the next folder, does the same thing and renames it as DATA_2.
The folders in the directory are named based on the date and day and time they were created. 2018102314-16-00, 2018102314-26-01, 2018102316-23-44 etc. The file DATA in the oldest folder should be renamed to DATA_1.
Hope I am clear!
Thank you

답변 (1개)

awezmm
awezmm 2018년 11월 2일
You can use the movefile function: movefile
It would work like: movefile source destination.
You may also need to make filepaths for the destination so this may help: fullfile
  댓글 수: 2
sarah Abdellahi
sarah Abdellahi 2018년 11월 2일
Thanks you for your response. But I cannot see how it finds the folder based on the date/time it has been created! I want to rename the files in a chronically order automatically. The DATA.mat file in the oldest folder rename to DATA_1 ... The DATA.mat file in the newest folder rename to DATA_550
awezmm
awezmm 2018년 11월 2일
편집: awezmm 2018년 11월 2일
Can it be sorted by date last modified and is there only one file in each of those folders

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by