How to go through multiple different naming folders for the same subfolder name
Show older comments
Greetings I have, on a Mac, 1472 main folders(dates+barcode) and within each of those, I have a subfolder (Hyp_90) that contains 244 images. The second image 2_0_0 needs to be skipped as it is a blank.
The information in all of the subfolders is named the same (even down to the blank image) the only thing that changes is the date and barcode of each main folder.
I have read the Matlab 'dir()' reading material but I wonder if I should also be looking at something else
Any guidance is appreciated and Thank you
Accepted Answer
More Answers (2)
Ameer Hamza
on 21 May 2018
0 votes
See this FEX submission: https://www.mathworks.com/matlabcentral/fileexchange/15859-subdir--a-recursive-file-search. Unlike dir which only search current folder. It will recursively search folder and its subfolders.
1 Comment
Guillaume
on 21 May 2018
dir has been able to perform recursive listing for a few versions now.
Guillaume
on 22 May 2018
dir has been able to perform recursive searches for a few versions now, so if all you want to do is get a list of all the files in all the subdirectories, then:
rootfolder = 'Volumes/SomeFolder/Somewhere/'; %folder with the 1472 subfolders
allfiles = dir(fullfile(rootfolder, '*', 'Hyp_90', '*.png'));
allfiles(strcmp({allfiles.name}, '2_0_0.png')) = []; %get rid of the 2_0_0.png images in the list
If you need to build the full path to all these files, it's simply:
fullfile({allfiles.folder}, {allfiles.name})
Categories
Find more on Convert Image Type 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!