Copying files based on text in argument
Posted: 10 Jun 2009 08:39
I have several text files that arrive in a folder for processing. once these files arrive, I need to use a batch file to identify certain information from the filename and copy that file to a specific folder named after that file.
Sample scenario:
1) "ABCD_1234_a1b2c3d4_AB1CD2.txt.gz" arrives in folder "C:\Drop Off\".
2) MoveFile.bat is called with the parameter: "C:\Drop Off\ABCD_1234_A1B2C3D4_AB1CD2.txt.gz"
3) Grab "A1B2C3D4" from the filename
4) Test for folderpath "C:\Test Data\A1B2C3D4\". If it doesn't exist, create it.
5) Test for the filename "C:\Drop Off\ABCD_1234_A1B2C3D4_AB1CD2.txt.gz". If exists, exit batch, else copy the file. I disregard the filedate & other attributes since files have a timestamp within the filename.
Any suggestions on how this would be accomplished is appreciated.
Sample scenario:
1) "ABCD_1234_a1b2c3d4_AB1CD2.txt.gz" arrives in folder "C:\Drop Off\".
2) MoveFile.bat is called with the parameter: "C:\Drop Off\ABCD_1234_A1B2C3D4_AB1CD2.txt.gz"
3) Grab "A1B2C3D4" from the filename
4) Test for folderpath "C:\Test Data\A1B2C3D4\". If it doesn't exist, create it.
5) Test for the filename "C:\Drop Off\ABCD_1234_A1B2C3D4_AB1CD2.txt.gz". If exists, exit batch, else copy the file. I disregard the filedate & other attributes since files have a timestamp within the filename.
Any suggestions on how this would be accomplished is appreciated.