필터 지우기
필터 지우기

Uigetdir to pick multiple directories

조회 수: 126 (최근 30일)
Robbie
Robbie 2011년 11월 25일
댓글: Image Analyst 2020년 5월 20일
I was wondering if anyone knows a simple way how to use uigetdir to select multiple directory paths in a similar way to using uigetfile with 'multiselect','on'
Thanks

답변 (2개)

Image Analyst
Image Analyst 2011년 11월 25일
Not that I know of with uigetdir. However it could work if you searched your hard drive for directories and then listed them all in a very wide listbox where the user could click on multiple directory names right from the listbox. You could use genpath() to load up the listbox.
  댓글 수: 3
Terry Furqan
Terry Furqan 2020년 5월 20일
i use this to create
root = uigetdir;
sd = genpath(root);
subdir = regexp(sd,';','split');
for k = 2:length(subdir)
F = dir(fullfile(char(subdir(k)), '*.csv')); %some process
end
Image Analyst
Image Analyst 2020년 5월 20일
You don't need to do char(subdir(k)) -- you can simply do subdir{k} to get the contents of the cell. See the FAQ.
startingFolder = pwd;
root = uigetdir(startingFolder);
allSubfolders = genpath(root)
subFolders = regexp(allSubfolders, ';', 'split')
for k = 2 : length(subFolders)
% Get this subfolder.
thisSubFolder = subFolders{k};
% Get a list of CSV files in this subfolder.
theseFiles = dir(fullfile(thisSubFolder, '*.csv'));
fprintf('Found %d CSV files in %s.\n', length(theseFiles), thisSubFolder);
% Some process to use the files.
end
Also, to be clear, this code does not allow the user to specify multiple folders individually. It allows the user to pick a top level folder, and then ALL subfolders under that top folder are examined.

댓글을 달려면 로그인하십시오.


Robbie
Robbie 2011년 11월 25일
I found a function on the file exchange that seems to work the way i want it 'uipickfiles' but i am open to other ways how to do this. Thanks

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by