I do not know for this a single-function method, but you can use genpath to recombine only a list of subdirectories. This list is returned as a string of directories with semicolons, so you have to separate it using strread, i.e.
dirlist = strread(genpath('/path/of/directory'),'%s','delimiter',';')
If you do not want to include this directory, delete the first dirlist entry, i.e. dirlist(1)=[]; because it is always the first record.
Then get a list of files in each directory with a looped dir .
filenamelist=[]; for d=1:length(dirlist) % keep only filenames filelist=dir(dirlist{d}); filelist={filelist.name}; % remove '.' and '..' entries filelist([strmatch('.',filelist,'exact');strmatch('..',filelist,'exact'))=[]; % or to ignore all hidden files, use filelist(strmatch('.',filelist))=[]; % prepend directory name to each filename entry, separated by filesep* for f=1:length(filelist) filelist{f}=[dirlist{d} filesep filelist{f}]; end filenamelist=[filenamelist filelist]; end
filesep returns the directory separator for the platform on which MATLAB is running.
This gives you a list of file names with full paths in the filenamelist of the cell array. I do not know how to do that.
JS Ng Apr 16 '10 at 15:08 2010-04-16 15:08
source share