Skip to content

Instantly share code, notes, and snippets.

@shane5ul
Last active December 20, 2015 06:59
Show Gist options
  • Save shane5ul/6090228 to your computer and use it in GitHub Desktop.
Save shane5ul/6090228 to your computer and use it in GitHub Desktop.
Loops through files in a directory that match a certain pattern
% 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