I have a MATLAB script that reads some data from a text file and then does some calculations and writes to another file. I would like to run this script for several thousand files in the same directory that don't have very similar file names. I was wondering how you would go about doing something like this. Is there anything in MATLAB similar to the find command in linux, which allows you to run a command for every file in a directory?
Thank you!
Maybe you could use ideas in:
http://www.mathworks.com/matlabcentral/fileexchange/22544-recursive-directory-walk-with-exec-unix-type
See question 4.12 in the newsgroup FAQ. You will need to have some way
either to generate a list of the files you want to process or to determine,
given a file name, whether you want to process it.
--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
one of the solutions
d=dir('*'); % <- retrieve all names: file(s) and folder(s)
d=d(~[d.isdir]); % <- keep file name(s), only
d={d.name}.'; % <- file name(s)
nf=numel(d);
for i=1:nf
disp(sprintf('working on %5d/%5d: %s',i,nf,d{i}));
% do something, eg,
% type(d{i});
end
us
Thank you very much!