Info
This question is closed. Reopen it to edit or answer.
I have a folder splitted.frames, It contains subdirectories like "21434343", "125521","25778" and so on. (random numbers as sub-directory name) Each subdirectory have thousand of images.
1 view (last 30 days)
Show older comments
I need to make, my code generic that it read all subdirectories one by one and I have written a piece of code that work really fine for single directory and process all files in it. How should a program select sub-directory one by one. please help me out.
0 Comments
Answers (1)
Walter Roberson
on 2 Aug 2015
master_folder = 'splitted.frames';
master_dinfo = dir(master_folder);
master_dinfo = master_dinfo([master_dinfo.isdir]);
now master_dinfo contains information only for subdirectories and you can loop
for K = 1 : length(master_dinfo)
this_folder_name = master_dinfo(K).name;
if this_folder_name(1) == '.'; continue; end %skip '.' and '..'
subdir_name = fullfile(master_folder, this_folder_name);
subdir_dinfo = dir(subdir_name);
subdir_dinfo([subdir_dinfo.isdir]) = []; %remove directories
for L = 1 : length(subdir_dinfo)
this_filename = fullfile( subdir_name, subdir_dinfo(L).name );
... now process this_filename
end
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!