필터 지우기
필터 지우기

Get files from many directories

조회 수: 1 (최근 30일)
Ramiro Rea
Ramiro Rea 2017년 8월 8일
댓글: Ramiro Rea 2017년 8월 8일
Hi everyone,
I have a list of directories from which I would like to get the names of the files that they hold. An example list is attached. Then I would like to create an unified list with all the names of those files (from all the folders). I will need this list of files to feed it to another function. I hope this makes sense. I know that maybe using the function dir can help me with this, but I haven't found a way to implement it so it can read every cell from the folder list and get me the contents of it. I would appreciate your help.
Many thanks, Ramiro

채택된 답변

Image Analyst
Image Analyst 2017년 8월 8일
See attached demos, for before and after release R2016b.
If you want, you could strip off the folder and call unique() on the base file names.
  댓글 수: 1
Ramiro Rea
Ramiro Rea 2017년 8월 8일
Thanks a lot for this. In the end I did a simpler solution with the code I already had.
%%Get Subject ID
subid = inputdlg('Type Subject ID');
subid = str2double(subid{1});
%%Get the subfolder path
orig = ['/home/dantes/Documentos/Gambling_fmri/Originals/s' num2str(subid)];
sub = dir(orig); %get the subfolder names
subname = {sub(3).name};
subPathN = fullfile(orig,subname);
subPath = subPathN{1};
%%Fetch all IMA files in those folders.
filePattern = sprintf('%s/**/*.IMA', subPath);
allFiles = dir(filePattern);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by