how to rename images from a folder?

3 ビュー (過去 30 日間)
Sahar abdalah
Sahar abdalah 2015 年 11 月 30 日
回答済み: Image Analyst 2015 年 11 月 30 日
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.

回答 (2 件)

Guillaume
Guillaume 2015 年 11 月 30 日
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 2015 年 11 月 30 日
You can use movefile(). Be sure to use fullfile() if you want the renamed files to live in a different folder.

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by