Skip to content

Instantly share code, notes, and snippets.

@tonyfast
Created September 17, 2014 23:42
Show Gist options
  • Select an option

  • Save tonyfast/709978c700a5a37ffdae to your computer and use it in GitHub Desktop.

Select an option

Save tonyfast/709978c700a5a37ffdae to your computer and use it in GitHub Desktop.
Create a File Name List Recursively through a directory in matlab
d = cd
paths = strsplit( genpath( d ), ':' );
fo = fopen( 'list.txt', 'w')
for pp = 1 : numel( paths )
ff = dir( paths{ pp } )
[~,b] = fileparts(paths{pp})
if numel( ff ) > 0 & numel(strfind(paths{pp},'.git')) == 0
b = arrayfun( @(x)x.name(1)~='.' & ~logical( x.isdir), ff(:))
fprintf( fo, horzcat( paths{pp}, filesep,'%s\n'),ff(b).name);
end
end
fclose(fo)
@awhite40

Copy link
Copy Markdown

I had to make a few edits to get it to work for me. I can't seem to make a pull request so here is the url for my fork of this code: https://gist.github.com/awhite40/21a7d5d13f8e44ecd72c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment