Renaming files in a folder
7 views (last 30 days)
I'm written the following code to rename files in a folder. However, for whatever reason it is not working. Any idea where I've gone wrong?
I assume the program is self-explanatory, but let me know if you need any clarifications on the task.
path=('D:\Documents and Settings\Administrator\Desktop\Data 31052012\75mj\all times\');
newName=([prefix num2str(time) 'ns'])
Walter Roberson on 4 Jun 2012
The directory name is not included in the .name field returned by dir(). You need to add it back on.
movefile( fullfile(path, files(id).name), fullfile(path, sprintf('%s.bmp',newName)) );