Link to home
Start Free TrialLog in
Avatar of Brugge2
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%.xlsx

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
Avatar of SysExpert
SysExpert
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree with SysExpert, you want to use Robocopy! =)

Try this command, it will move only files older than 7 days:

Robocopy "\\Server\Share\Source" "\\Server\Share\Destination" * /ZB /R:2 /W:2 /MINAGE=7

=)

NOTE:  You can not have a trailing "\" on the source or destination!


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial