From: Diana on
"us " <us(a)neurol.unizh.ch> wrote in message <hoj0h1$3c1$1(a)fred.mathworks.com>...
> "Diana " <diana.qiu(a)yale.edu> wrote in message <hoivup$n41$1(a)fred.mathworks.com>...
> > Hello everyone,
> >
> > 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!
>
> 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!