How to read folders of diferent names extensions

1 view (last 30 days)
Dear all, I have folders the name of which is e.g. 000003.537, 000003.637, 000004.037. In each folder is one image file and the name of all image files is the same e.g. 000001.tiff. I am looking for the way how to take out images from all folder and copy them into new folder.
Now I do that in a simple way, that I rename all folder to e.g. 000001, 000002, 000003,... and in such a way I go around the issue with such name 000003.537.
The different name of folder and the changing extension is my problem.
I will appreciate any advice which will lead to more elegant solution. Ludek

Accepted Answer

Oleg Komarov
Oleg Komarov on 8 Aug 2012
% retrieve all subfolders's names
s = dir('yourpath');
idx = [s(:).isdir];
names = {s(idx).name}';
% Remove . and ..
names = setdiff(names,{'.','..'});
Now you can loop through each names and movefile() which is inside.

More Answers (1)

Ludek
Ludek on 8 Aug 2012
Thank you, now it works well1 Best,Ludek

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!