Brugge2
asked on
Batch File Date Format
I have some reports with a date stamp in the name.
These are created with a batch file. The file exports and it then renamed using:
COPY [original name].xlsx [File Location]\[File Name]-%date:~-4,4%%date:~- 10,2%%date :~-7,2%.xl sx
Question is:
I would like to archive these reports to another location after 7 days.
Using the batch file, what is the syntax to move the file date stamped 7 days earlier? The date format (using today's date) created by the code above is: [file name]-20100811.xlsx
The ideal result would be to have my current line that renames the file and add a second line which then moves the 7 day old file to a different location.
Thanks.
These are created with a batch file. The file exports and it then renamed using:
COPY [original name].xlsx [File Location]\[File Name]-%date:~-4,4%%date:~-
Question is:
I would like to archive these reports to another location after 7 days.
Using the batch file, what is the syntax to move the file date stamped 7 days earlier? The date format (using today's date) created by the code above is: [file name]-20100811.xlsx
The ideal result would be to have my current line that renames the file and add a second line which then moves the 7 day old file to a different location.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this command, it will move only files older than 7 days:
Robocopy "\\Server\Share\Source" "\\Server\Share\Destinatio
=)
NOTE: You can not have a trailing "\" on the source or destination!