I have a file that needs to be opened and renamed on a daily basis. PART of the filename changes daily so I want to open the file using the "*". Here is part of the script I have so far:
I first want to locate the file and see if the file is there. In this case the file name is "ETCTXT02292295P.091008.024310001.txt" The first part of the file name does not change "ETCTXT02292295P." and the second part is the date. The final part of the file name changes daily and it's not something I can determine. When I run IfFileExists using the formula below, it will correctly tell me if the file exists or not. After that is complete I want to open the file and that is where I'm having problems. Any suggestions?
Day>theDay
Month>theMonth
Year>theYear
//GET LAST TWO DIGITS OF YEAR
MidStr>theYear,3,2,theYear
//DETERMINE YEAR
ifFileExists>T:\IQ\DATA\COMM\outbound\outbound\ETCTXT02292295P.%theMonth%%theDay%%theYear%*,Open
Label>Open
ExecuteFile>T:\IQ\DATA\COMM\outbound\outbound\ETCTXT02292295P.%theMonth%%theDay%08*
Thanks in advance,
Dominic
Opening a File with Wildcard
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You should use GetFileList to retrieve a list of matching files (which by your email I assume would contain just one file). Loop through the returned list to get each FULL filename. Then you can open it.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanks for the quick reply!
I would like to first make sure the file exists, then open it (there could be 5+ files in the folder, but only one with that filename). After this is found I would like to open it, rename it then close it. Obviously this should be fully automated.
I'm not sure I follow what you are saying by retrieving the list of file names. If I run GetFileList on that folder, would it manually generate the list or would it just be in memory? What command would I use to open the one I'm looking for?
Sorry - I'm still a bit confused.
Thanks,
Dom
I would like to first make sure the file exists, then open it (there could be 5+ files in the folder, but only one with that filename). After this is found I would like to open it, rename it then close it. Obviously this should be fully automated.
I'm not sure I follow what you are saying by retrieving the list of file names. If I run GetFileList on that folder, would it manually generate the list or would it just be in memory? What command would I use to open the one I'm looking for?
Sorry - I'm still a bit confused.
Thanks,
Dom
From Help for GetFileList>
Try something like this:
The results of GetFileList are stored in a variable. That variable's contents can be searched using the Position> function to determine if a given string (your file name) is contained in the contents. Once the position is found Midstr> and Separate> can be used to isolate the file from the rest of the list.GetFileList>filespec,result[,delimiter]
GetFileList returns a list of the files found matching the specified filespec. For instance, to return the list of files in the temp directory specify c:\temp\*.* as the filespec.
If delimiter is ommitted each filename is separated by a semicolon (;). Otherwise the filenames are separated by the delimiter specified.
Try something like this:
Code: Select all
Day>theDay
Month>theMonth
Year>theYear
//GET LAST TWO DIGITS OF YEAR
MidStr>theYear,3,2,theYear
//DETERMINE YEAR
GetFileList>T:\IQ\DATA\COMM\outbound\outbound\*.txt,filelist
Let>filename=ETCTXT02292295P.%theMonth%%theDay%%theYear%
Position>%filename%,%filelist%,1,pos
Midstr>filelist,pos,1000000,filetest
separate>filetest,;,file
ExecuteFile>T:\IQ\DATA\COMM\outbound\outbound\%file_1%