| Date: | Wed, 23 Feb 2005 15:14:26 -0800 |
| Reply-To: | cassell.david@EPAMAIL.EPA.GOV |
| 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 |
| In-Reply-To: | <1109121068.509686.63340@l41g2000cwc.googlegroups.com> |
| Content-type: | text/plain; charset=US-ASCII |
|---|
enstrophy <enstrophy_2000@yahoo.com> 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.,
>
> c:/folder_01
> a.dat
> b.dat
>
> c:/folder_211
> 101.dat
> a2.dat
>
> 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
--
David Cassell, CSC
Cassell.David@epa.gov
Senior computing specialist
mathematical statistician
|