Maddy
Maddy

Reputation: 2570

view .m files in a folder (including subFolders) in MATLAB

I have a Folder Factors inside Project folder. (all inside MyDocuments/Matlab). I need the list of all .m files in the folder FACTORS. Factors has subFolders and these subFolders hold all the .m files. Any suggestions?

Directory Design ->

Project...
    Factors ... etc
       subFol1 (has .m files)
       subFol2 (has .m files)
    ...

Upvotes: 0

Views: 1626

Answers (2)

lijinfeng042
lijinfeng042

Reputation: 36

I have solved a similar problem.On Windows platforms, ,Like this:

pathName='.... \FACTORS';%your path
[stat path]=dos(['dir ' pathName '\*.m /s /B >path.txt'] );
name=importdata('path.txt');
delete path.txt

Now,you can see all files which matches the conditions is in the cell array "Name"

Upvotes: 1

Chris
Chris

Reputation: 46316

This function would be useful. It will recursively search folders, executing a user defined function on each directory. You will need to write your own function to list all .m files in the current directory.

Upvotes: 1

Related Questions