Hi all,
I receive a batch of files each weekend that contain files I want to read into Stata that are intermixed with files I do not want to read in. I have been unable to crack how to select only a portion of files based on the characters in the file names.
An example of a file I want is: "01-AZ.dat" or "17-IL.dat", i.e., [0-9][0-9][\-][A-Z][A-Z][\.dat]
An example of a file I do not want is: "Bermuda.dat" or "readme.dat", hence ([a-zA-Z]+)[\.dat]
I start by creating a dir of the files that then I loop through. I currently have "*" in to select all of the dat files, which does not work, of course.
***
local files : dir . files "*.dat" //
foreach f of local files {
***
*ado continues>
Is there anyway to select only the files want in either the dir command or the foreach command? Instead would this be accomplished another way.
Thanks, in advance, for whatever advice you might have.
Ben
I receive a batch of files each weekend that contain files I want to read into Stata that are intermixed with files I do not want to read in. I have been unable to crack how to select only a portion of files based on the characters in the file names.
An example of a file I want is: "01-AZ.dat" or "17-IL.dat", i.e., [0-9][0-9][\-][A-Z][A-Z][\.dat]
An example of a file I do not want is: "Bermuda.dat" or "readme.dat", hence ([a-zA-Z]+)[\.dat]
I start by creating a dir of the files that then I loop through. I currently have "*" in to select all of the dat files, which does not work, of course.
***
local files : dir . files "*.dat" //
foreach f of local files {
***
*ado continues>
Is there anyway to select only the files want in either the dir command or the foreach command? Instead would this be accomplished another way.
Thanks, in advance, for whatever advice you might have.
Ben
Comment