Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: How to execute all the matlab file under a directory?

Subject: How to execute all the matlab file under a directory?

From: zhengquan

Date: 10 May, 2008 02:13:59

Message: 1 of 3

Hello,

I have a directory with lots of subdirectories, in the
subdirectories, there are the same scripts to anylyse data
stored in them. Now I want to traverse the entire directory
and get the matlab scripts executed in all the
subdirectories. I am running a linux system. Can anyone tell
me how to do that? Thanks!

Regards,
Zhengquan

Subject: Re: How to execute all the matlab file under a directory?

From: carlos lopez

Date: 10 May, 2008 11:50:18

Message: 2 of 3

zhengquan <zhang.zhengquan@gmail.com> wrote in message
<98432fb4-2bd1-4390-bfeb-782fcd0f4a3b@m36g2000hse.googlegroups.com>...
> Hello,
>
> I have a directory with lots of subdirectories, in the
> subdirectories, there are the same scripts to anylyse data
> stored in them. Now I want to traverse the entire directory
> and get the matlab scripts executed in all the
> subdirectories. I am running a linux system. Can anyone tell
> me how to do that? Thanks!
>
> Regards,
> Zhengquan
In order to locate all the files with a given sufix, in
linux you can issue the following command in the top directory:

find . -name "*.m" -print
If you want to do this from within matlab, you can resort to
the unix command:
unix('find . -name "*.m" -print')
but I cannot assure how you get the output, etc.
Regards
Carlos

Subject: Re: How to execute all the matlab file under a directory?

From: John D'Errico

Date: 10 May, 2008 12:32:03

Message: 3 of 3

"carlos lopez" <clv2clv_00000000_@adinet.com.uy> wrote in message
<g0425q$8d7$1@fred.mathworks.com>...
> zhengquan <zhang.zhengquan@gmail.com> wrote in message
> <98432fb4-2bd1-4390-bfeb-
782fcd0f4a3b@m36g2000hse.googlegroups.com>...
> > Hello,
> >
> > I have a directory with lots of subdirectories, in the
> > subdirectories, there are the same scripts to anylyse data
> > stored in them. Now I want to traverse the entire directory
> > and get the matlab scripts executed in all the
> > subdirectories. I am running a linux system. Can anyone tell
> > me how to do that? Thanks!
> >
> > Regards,
> > Zhengquan
> In order to locate all the files with a given sufix, in
> linux you can issue the following command in the top directory:
>
> find . -name "*.m" -print
> If you want to do this from within matlab, you can resort to
> the unix command:
> unix('find . -name "*.m" -print')
> but I cannot assure how you get the output, etc.
> Regards
> Carlos
>

Its far easier to do in matlab. dir will do what
the OP wants. However, if you want to look
recursively through the deeper directories,
then you will want to use a tool that supports
such a search. There are many of them on the
file exchange. Just pick one out.

http://www.mathworks.com/matlabcentral/fileexchange/loadCategory.do?
objectId=38&objectType=Category

John

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics