Last active
December 20, 2015 06:59
-
-
Save shane5ul/6090228 to your computer and use it in GitHub Desktop.
Loops through files in a directory that match a certain pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% matches pattern NL300/L0.1 etc | |
% stores the result in a cell structure | |
dirList = glob("NL*/L*"); | |
% Loop through the elements of the cell | |
for i = 1:length(dirList) | |
dirname = dirList{i,1}; % pick out individual item | |
cd(dirname) % note cd dirname won't work | |
pwd % do whatever you want | |
cd ../../ | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment