Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Batch renaming based on .csv/.xls
Posted:
Jul 7, 2014 3:45 PM


I'm trying to rename a batch of files within MATLAB using codes from an external spreadsheet. I'm using a Mac. Here is a sample from the spreadsheet that includes the codes I need:
Base L1 C3 C2 C3 Base C2 L1
And this is a sample list of files:
PWSM10A_2014_05_23_112132_001_Odau_1.wav PWSM10A_2014_05_23_112132_002_Odau_1.wav PWSM10A_2014_05_23_112132_003_Odau_1.wav PWSM10A_2014_05_23_112132_004_Odau_1.wav PWSM10A_2014_05_23_112132_005_Odau_1.wav PWSM10A_2014_05_23_112132_006_Odau_1.wav PWSM10A_2014_05_23_112132_007_Odau_1.wav PWSM10A_2014_05_23_112132_008_Odau_1.wav
Both lists will always be in the correct (corresponding) order. I want the codes to appear at the beginning of the file names, followed by "_" (e.g., "Base_PWSM10A_2014_05_23_112132_001_Odau_1.wav", "L1_PWSM10A_2014_05_23_112132_002_Odau_1.wav", and so on).
I have attempted to use csvread, textread, and textscan, together with movefile, but have been unsuccessful. One major obstacle has been that MATLAB appears to not (easily) read strings of varying length. It may go without saying, but I am MATLAB novice. I would appreciate any help anybody is willing to offer.
Thank you!
Eric



