File Rename based on date.
Moderators: JRL, Dorian (MJT support)
File Rename based on date.
I have several files located and named as follows:
S:\CTV\102904pool55inv.txt
This file is auto created every day and the modified date reflecting each day. I need to automatically look in this directory for these files that are new every morning and rename then and copy them to this location:
\\MINT02\Share\SHARE\SMP\Dialer_Recon\pool55inv.txt
This then allows me to complete an automation within an Access database.
Any ideas??
Much appreciated!
Shawn.
S:\CTV\102904pool55inv.txt
This file is auto created every day and the modified date reflecting each day. I need to automatically look in this directory for these files that are new every morning and rename then and copy them to this location:
\\MINT02\Share\SHARE\SMP\Dialer_Recon\pool55inv.txt
This then allows me to complete an automation within an Access database.
Any ideas??
Much appreciated!
Shawn.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Two quick skeleton structures:
----------------------------
Use System date, and parse it to get components for filename.
Month>MM
Day>DD
Year>YYYY
MidStr>%Year%,3,2,YY
Use %MM%%DD%%YY% when looking for the file name
Let>FileName=%MM%%DD%%YY%pool55inv.txt
------------------------
or
Use FileDate> and compare results to known value. If changed then do MoveFile>
You could use todays date as a reference.
or
Compare FileDate to a value in an INI file. Update the INI value every time you move the existing file.
-------------------
----------------------------
Use System date, and parse it to get components for filename.
Month>MM
Day>DD
Year>YYYY
MidStr>%Year%,3,2,YY
Use %MM%%DD%%YY% when looking for the file name
Let>FileName=%MM%%DD%%YY%pool55inv.txt
------------------------
or
Use FileDate> and compare results to known value. If changed then do MoveFile>
You could use todays date as a reference.
or
Compare FileDate to a value in an INI file. Update the INI value every time you move the existing file.
-------------------
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Format
Thanks so much for your reply Bob. I am so new to this. So, how would this scrupt look laid out. Am I replacing my filename is the variable "FileName". And when I write the line to copy, what does the syntax look like.
I really appreciate your assistance!
Shawn.
I really appreciate your assistance!
Shawn.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Put together your script and submit here if you have problems. Explain where the problem is happening and what you are seeing for symptoms of problems.And when I write the line to copy, what does the syntax look like.
Maybe use this structure as a starting point. This is untested
Try starting with the Help file for each of the commands and variables, and look at the Help examples. You can also single step through the script and look at the values in the Watch List. And you can read your log and see what happened, what variable values were, and time and sequence commands were executed/skipped.Let>SourcePath=S:\CTV
Let>DestPath=\\MINT02\Share\SHARE\SMP\Dialer_Recon
Month>MM
Day>DD
Year>YYYY
MidStr>%Year%,3,2,YY
Let>FileName=%MM%%DD%%YY%pool55inv.txt
IfFileExists>%SourcePath%\%FileName%,CopyIt
MessageModal>File %Filename% was NOT found in %SourcePath%%CRLF%CRLF%No file copied. Process Stopped.
Goto>End
Label>CopyIt
MoveFile>%SourcePath%\%FileName%,%DestPath%\%FileName%,
MessageModal>File %Filename% was found in %SourcePath%.%CRLF%%CRLF%. File was copied to %DestPath%.
Label>End
If copying script from forum be sure to remove any trailing spaces. Latest version does warn you of trainling spaces. And Variables and Labels are Case Sensitive.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Close!
Thanks for your assistance Bob, so very much appreciated! Everythings seems to run smooth, with the exception of the following MidStr command. After stepping through, it looks for the filename:
1102eapool55inv.txt
MidStr>%Year%,3,2,YY
Let>FileName=%MM%%DD%%YY%pool55inv.txt
I attempted changing some of the values but the closest I got was in getting the full YYYY format in the file name.
Thanks again!!!
1102eapool55inv.txt
MidStr>%Year%,3,2,YY
Let>FileName=%MM%%DD%%YY%pool55inv.txt
I attempted changing some of the values but the closest I got was in getting the full YYYY format in the file name.
Thanks again!!!
Good advice
Bob, I took your advice and studied the Syntax and found that by replacing this:
MidStr>%Year%,3,2,YY
With this:
MidStr>%YYYY%,3,2,YY
It corrected the issue.
Thanks so much for your guidance!
Shawn.
MidStr>%Year%,3,2,YY
With this:
MidStr>%YYYY%,3,2,YY
It corrected the issue.
Thanks so much for your guidance!
Shawn.
mmm
Everything looks fine and it says the file has been copied correctly, but when I look in the destination folder, it does not exist??
Any ideas?
Shawn
Any ideas?
Shawn
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Hello smpayne. Good catch on the %YYYY% vs. the %Year%. I warned you it was untested
It is possible that the file did not get copied. That was a basic structure that I provided. This script message happens regardless of whether the file was copied or not.
Normally after a MoveFile, CopyFile, etc. you would frequently have some other commands to check that it happened, something like IfFileExists> SendMessageOK,SendMessageNG; or maybe FileDate> result would be analyzed, etc.
Make a log and look at the log results, or Single Step while looking at the Watch List to see the values of the variables.


Normally after a MoveFile, CopyFile, etc. you would frequently have some other commands to check that it happened, something like IfFileExists> SendMessageOK,SendMessageNG; or maybe FileDate> result would be analyzed, etc.
Make a log and look at the log results, or Single Step while looking at the Watch List to see the values of the variables.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Step looks good
Bob, the step looks good and appears to execute. I put an IfFileExists check on the destination and it comes up successful. I even tried changing to a locat directory, but still no file. Here is what I have right now:
Let>SourcePath=S:\CTV
Let>DestPath=\\MINT02\Share\SHARE\SMP\DialerRecon
Month>MM
Day>DD
Year>YYYY
MidStr>%YYYY%,3,2,YY
Let>FileName=%MM%%DD%%YY%pool55inv.txt
Let>NewFileName=pool55inv.txt
IfFileExists>%SourcePath%\%FileName%,CopyIt
MessageModal>Unable to locate %Filename% in %SourcePath%%CRLF%CRLF%No file copied. Process Stopped.
Goto>End
Label>CopyIt
CopyFile>%SourcePath%\%FileName%,%DestPath%\%NewFileName%,
MessageModal>File %Filename% was found in %SourcePath%.%CRLF%%CRLF%. File was copied to %DestPath%.
IfFileExists>%DestPath\%NewFileName%,Success
Label>Success
MessageModal>File Found
Goto>End
Label>End
Any ideas??
Thanks again Bob!!
Let>SourcePath=S:\CTV
Let>DestPath=\\MINT02\Share\SHARE\SMP\DialerRecon
Month>MM
Day>DD
Year>YYYY
MidStr>%YYYY%,3,2,YY
Let>FileName=%MM%%DD%%YY%pool55inv.txt
Let>NewFileName=pool55inv.txt
IfFileExists>%SourcePath%\%FileName%,CopyIt
MessageModal>Unable to locate %Filename% in %SourcePath%%CRLF%CRLF%No file copied. Process Stopped.
Goto>End
Label>CopyIt
CopyFile>%SourcePath%\%FileName%,%DestPath%\%NewFileName%,
MessageModal>File %Filename% was found in %SourcePath%.%CRLF%%CRLF%. File was copied to %DestPath%.
IfFileExists>%DestPath\%NewFileName%,Success
Label>Success
MessageModal>File Found
Goto>End
Label>End
Any ideas??
Thanks again Bob!!
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
I see a trailing comma on the line to CopyFile.
And your check for Success will give you a Success message in all cases.
Remove that commaCopyFile>%SourcePath%\%FileName%,%DestPath%\%NewFileName%,
And your check for Success will give you a Success message in all cases.
You need something like:IfFileExists>%DestPath\%NewFileName%,Success
Label>Success
MessageModal>File Found
Goto>End
IfFileExists>%DestPath\%NewFileName%,Success,Fail
Label>Success
MessageModal>File Found
Goto>End
Label>Fail
MessageModal>File Not Found
Goto>End
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Thank you!
Works great!!! Thanks for the quick and helpfull lesson!
One last question.. How do I change the CL_OVERWRITE=0 variable to 1?? I have looked through the program and the .ini file, but cannot locate it.
Shawn
One last question.. How do I change the CL_OVERWRITE=0 variable to 1?? I have looked through the program and the .ini file, but cannot locate it.
Shawn
Sorry Bob, nevermind...me being stupid now!
Just used a Let statement.
Thanks for everything!!!! You saved me a lot of grief.
Thanks for everything!!!! You saved me a lot of grief.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: