how to rename images from a folder?

7 views (last 30 days)
Sahar abdalah
Sahar abdalah on 30 Nov 2015
Answered: Image Analyst on 30 Nov 2015
Hello every one, I have a folder 'SET1' that contain 60 folders (person_1, person_2,...,person_60). Each folder contain 50 images : SentenceImage_0, SentenceImage_1, ......,SentenceImage_49).
I want to rename and save these images in a single folder 'dataset': the name of each image is as follows: 1_SentenceImage0_SET1, 1_SentenceImage1_SET1, 1_SentenceImage2_SET1, ..., 1_SentenceImage50_SET1, 2_SentenceImage0_SET1 ... etc. with 1 corresponding to folder person_1, 2 corresponds to folder person_2, up to 60 corresponding to person_60.
Please, any suggestion for a matlab code and thanks in advance.

Answers (2)

Guillaume
Guillaume on 30 Nov 2015
While it's certainly possible to do this in matlab using dir, a for loop, and some simple path manipulation, there are plenty of tools freely available dedicated to renaming files which will be simpler to use and more importantly, don't require debugging (hence no risk of losing files because your script all rename them to the same file).
Personally, I would use IrfanView because I've got it installed on my machine (I'm in no way affiliated with the product) and it's trivial to do what you want with it. Use it to open any of your image. Press B, select batch rename, select all the files, select output directory. Write $d$N in the rename field. Press 'Start Batch', and you're done.

Image Analyst
Image Analyst on 30 Nov 2015
You can use movefile(). Be sure to use fullfile() if you want the renamed files to live in a different folder.

Community Treasure Hunt

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

Start Hunting!

Translated by