Hi jyw,
In addition to Jim's suggestion you could try the following generalized approach for selecting the files you want. See below for example:
allFiles = FilesInDirectory("$Documents", recursive);
selectedFiles = {};
commonName = "BrownP";
For( i = 1, i<=NItems(allFiles), i++,
If( !IsMissing( Regex(allFiles, EvalInsert(".*<commonName>.*\.csv","<",">" )) ),
InsertInto(selectedFiles, allFiles);
)
);
1. Retrieve all filenames in the My Documents folder and its subfolders. (Replace with your top level folder path).
2. Create an empty list to store the filenames you want.
3. Define the commonName string.
4. Loop through all filenames, selecting only the ones that match the pattern and store in the selectedFiles list. In this example I'm retrieving all the CSV files that contain "BrownP" in the filename. (Replace with your own commonName string).
So, the full implementation (using Jim's code from the previous post):
Names Default To Here( 1 );
// Setup an empty table to start to concatenate other tables to
dtbase = New Table( "Base Table" );
// Have the user select the starting folder
dirpath = Pick Directory( "Pick the Top Level Directory" );
// Get all of the files in all of the folders that are under the picked folder
TheFileList = Files In Directory( dirpath, "recursive" );
// Define common string to search for
commonName = "file";
// Go through all of the files and read in append those that meet your
// requirement. You will need to amend the IF statement to meet your criteria
For( i = 1, i <= N Items( TheFileList ), i++,
If( !Is Missing( Regex( TheFileList, Eval Insert( ".*<commonName>.*\.csv", "<", ">" ) ) ),
dt = Open( dirpath || TheFileList );
dtbase = dtbase << concatenate( dt, append to first table( 1 ) );
Close( dt, nosave );
)
);
Hope this helps!
Best,
Phil
PDB