How can I list file-paths from different subfolders?
5 views (last 30 days)
Show older comments
Eliska Sykorova
on 19 Sep 2018
Commented: Eliska Sykorova
on 19 Sep 2018
Hi,
I am looking for an option to create a list of paths of files which are stored in different subfolders. I have a big amount of data, which is stored in this way:
C:/directory01/person01/subdirectory01/file01.x
/subdirectory02/file01.x
/subdirectory03/file01.x
C:/directory01/person02/subdirectory01/file01.x
/subdirectory02/file01.x
/subdirectory03/file01.x
and so on...
I want so create different lists of paths which contain e.g. only 'the file01.x's' from 'subdirectory02' from each person.
So something like
C:/directory01/person*/subdirectory02/file01.x
Is this possible? I only find ways to choose every file01.x which exist in directory01 and have to delete afterwards by hand the files from 'subdirectory01' and '~03'
Thank you so much for your help!
Best Eliska
0 Comments
Accepted Answer
Fangjun Jiang
on 19 Sep 2018
You can use
f=dir('C:/directory01/person*/subdirectory02/file01.x')
2 Comments
OCDER
on 19 Sep 2018
And to get the the cell array of absolute paths to these files:
FileNames = fullfile({f.folder}, {f.name});
If you need to access many files for processing, and can't load them to memory, try datastore.
More Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!