[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Directory Listing in Octave -- Recursion
From: |
Greg_G |
Subject: |
Re: Directory Listing in Octave -- Recursion |
Date: |
Wed, 9 Dec 2009 08:26:08 -0800 (PST) |
Here is a Windows-specific method of recursion using "system" and the "dir"
command:
patdir= (['dir /b /s "',<directory>,'\*.dat"']);
[status data] = system ( patdir, 1);
Unfortunately, the string variable "data" is a (1 x N) char array and has to
be split into strings based on the end-of-line character "\n".
Is there anything a little cleaner?
Greg_G wrote:
>
> Hello,
>
> This should be an easy question but the answer is eluding me. I am
> running Windows XP Octave-3.2.3-3_i686-pc-mingw32.
>
> I am trying to create a cell array of file names of a specific extension
> from a tree of directories. Each of the files in the list will later be
> opened and scanned for data.
> I would like to use one “glob” or “dir” or “ls” command to search all
> levels of the tree for the file type.
>
> Currently, I am using "glob" but I have to specify a pattern for each
> hierarchical level and I have to know how many levels there are. Is there
> a way to search all of the unkown number of levels of subdirectories?
>
> The “dir /b /s” and “ls –R” commands look like they should work but I have
> not been able to get what I want using the system("dir /b /s") command.
>
> This is my current code:
>
> Data_dir= “X:\\Test_stand\\2009” % Base directory
> Pat1= {[Data_dir,”/*/*.dat”]}; % pattern for 1st level
> Pat2= {[Data_dir,”/*/*/*.dat”]}; % pattern for 2nd level
> Pat3= {[Data_dir,”/*/*/*/*.dat”]};
> ZZ= glob({pat1,pat2,pat3});
>
>
> Regards,
> Greg
>
>
>
>
--
View this message in context:
http://old.nabble.com/Directory-Listing-in-Octave-tp26631421p26713112.html
Sent from the Octave - General mailing list archive at Nabble.com.