mardi 30 juin 2015

Renaming files en mass in MATLAB

When collecting data, I've currently named my files in the following format:


Where the number before the underscore is a continent:

1- Africa
2- South America
3- Central America

The second number is the day in that continent the measurement was made on. What I'd like to do is to add the country the measurements were made in onto the end of the filename as well. For example:

1_1 --> 1_10 I want to rename each one to 1_1_Zaire --> 1_10_Zaire

1_11 --> 1_14, I want to rename each one to 1_11_Kenya --> 1_11_Kenya

How could I do this while keeping all the .mat files in the same folder? I'd prefer to use MATLAB for the renaming if possible.

I understand the algorithm will be something like the following:

  1. name a directory with all the .mat files
  2. make a for loop from bound 1 to bound x
  3. concatenate the phrase I want

The only problem is, I don't know how to get the length of the loop, and I don't understand how MATLAB reads files in a directory.

Aucun commentaire:

Enregistrer un commentaire