Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Help to rename files in order of date and time created

Asked by John on 12 Mar 2012

Hello,

I am hoping that somebody could perhaps help me out with a problem that I have. I'm trying to change the name of files with some matlab code.

I have a folder called Master folder.

In the Master folder I have 1500 sub-folders called for example

2012-0311-1339-26-750 and 2012-0312-1340-48-42. The first folder were created at 13:39 on Match 11th and the second folder on March 12th at 13:40.

In each folder there is a file called data.mat

I wanted to rename these data.mat files as cycle1, cycle2, cycle3...cycle1500 in order of the date and time that they were created. I also wanted to save them all to a new folder.

Would anybody know how I could do this. I have very little programming ability but keen to learn.

Sincere thanks

John

0 Comments

John

Tags

Products

No products are associated with this question.

1 Answer

Answer by Jacob Halbrooks on 12 Mar 2012

If "last modified" date is a good enough proxy for "created" date, then you can use DIR to find the dates for each file. You could use SORT with the DIR datenum field to get your list of files, and then COPYFILE to do the saving.

0 Comments

Jacob Halbrooks

Contact us