|Date: ||Wed, 23 Feb 2005 15:14:26 -0800|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||"David L. Cassell" <cassell.david@EPAMAIL.EPA.GOV>|
|Subject: ||Re: Scan files from multiple directories|
|Content-type: ||text/plain; charset=US-ASCII|
enstrophy <firstname.lastname@example.org> wrote:
> I'm attempting to read files with known extensions from multiple
> directories under windows. For example, I have several *.dat files
> under folders named folder_*, i.e.,
> Unlike in unix, the following expression:
> filename myfiles("c:/folder_*/*.dat")
> is not recognized by the windows xp shell.
> Since the number of folders will grow over time,
> it is not a good idea to hard code the folder names
> in the code. I wonder if anyone knows of a simple
> solution to this problem? Many thanks.
I see that Richard has already provided an excellent response.
(As always.) Take his advice.
And remember that win32 is not unix. I would have recommended
using Perl to do this, in much the same way, providing a pipe
into the DATA step. In ActiveState Perl for win32, the easiest
way to get this sort of wildcard expansion in filename and
directory listings thrown in at the command line (where it is
still subject to the whims of the OS) is the use of the File::DosGlob
module, or Jenda's G module (http://Jenda.McCann.cz/perl).
Now then, let me ask a question. Why are you using this directory
and file structure? It seems to be rather sub-optimal, and is likely
to continue to cause you more headaches as time (and hard drive space)
advances. Changing your storage structure could make your work
easier in future. Not to mention how awkward it will be to do
any file updates, file maintenance, data QA, ....
David Cassell, CSC
Senior computing specialist