Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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 回表示 (過去 30 日間)
maira alvi
maira alvi 2015 年 8 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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.

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 8 月 2 日
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

この質問は閉じられています。

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by