how to rename bunch of files

Hi experts,
I have 277 Image files ,like
zROI1FCMap_Sub011.img, zROI2FCMap_Sub011.img, zROI3FCMap_Sub011.img ..... zROI 277 FCMap_Sub011.img,
now I want to rename this to
zROI*218*FCMap_Sub011.img, zROI*219*FCMap_Sub011.img zROI*220*FCMap_Sub011.img...... zROI*494*FCMap_Sub011.img
Could any one please tell me how to rename?
Thank you
Pruthvi

3 Comments

You will have literal asterisks in your file names? That is possible, I guess, but it would likely tend to mess up anything that does wild-card processing.
Hi Walter, there are no asterisks in my file name, I just wanted to highlight the number which I wanted to rename so made it BOLD.
Thank you
Pruthvi
You need to put a space before the first asterisk and a space after the second asterisk to make it bold, like I did for your first one (which I edited). Though, that also puts in spaces in addition to making it bold. I'm not sure how to make it bold without having spaces in the output.

Sign in to comment.

 Accepted Answer

Sean de Wolski
Sean de Wolski on 28 Jun 2012

3 Comments

Hi Thanks a lot for your answer, I have one more doubt, that is since I have the file names from 1 to 277 in 1,2,3,4,...277 fashion, I think the matlab reads it as 10,100,101,...109 Could you please help me how to overcome this problem
with best regards
Pruthvi
So use sprintf() or num2str() to convert the number the way you want it.
Use two numbers (%n.nd) to pad your number with zeros and keep 10 right before 11 (actually 010 right before 011) rather than right before 100 like it normally would:
baseFileName = sprintf('zROI1FCMap_Sub%3.3d.img', imageNumber);
Note the %3.3d in the format string.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!