How to go through folder in a given folder?

21 ビュー (過去 30 日間)
Mr M.
Mr M. 2016 年 4 月 19 日
回答済み: Image Analyst 2016 年 4 月 19 日
How to go through folder in a given folder? I have the folder from uigetdir.

回答 (2 件)

Ced
Ced 2016 年 4 月 19 日
Hi
You can use dir to list all the files and folders on a particular folderpath, and then extract only the folders.
e.g.
folderpath = 'new_folder';
all_objects = dir(folderpath);
% all_objects(1:2) = []; % you possibly want to get rid of . and ..
all_dirs = all_objects([all_objects.isdir]==1);
Now you can loop through the folders. Is that what you were looking for?

Image Analyst
Image Analyst 2016 年 4 月 19 日
You can use genpath(folderpath) to get a cell array of all subfolder names.
Or if you want to process all files in all subfolders, then see my attached demo.

カテゴリ

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