Rename A Lot of Files
Show older comments
Hello, can anyone tell me how to rename a lot of files? I have a problem because my files name have a type like this (YR.ME01..HHZ.D.2013.280.000000.SAC), but I need it to be like this (2013.280.00.00.00.000.YR.ME01.BHZ.SAC). Thank you for your help.
Answers (1)
Adam
on 24 Jun 2015
movefile('source','destination')
doc movefile
works for renaming a file. If it is in the current folder you can just put old and new filenames, otherwise you also have to add the path.
To rename a lot of files just do it in a loop. It depends where you are getting the names from how best to do that though. If it is all files in a folder you can use
doc dir
and query its results for filenames of the required format then write a function that takes an old name and converts it to a new name, then call it on all your files, using movefile as above to save each one.
1 Comment
Stephen23
on 24 Jun 2015
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!