Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a .Bat file for backup's

Status
Not open for further replies.

Techguy2009

Technical User
Nov 10, 2009
12
US
Hello,

I am sort of new to making .Bat files. I don't think I have made one since I was a little kid using windows 3.1. Anyways, I am trying to accomplish a .bat file that copies files from on pc to the other, only for the last 7 days, and I would like it to delete anything older than 7days on both pc's.

I have the copy with 7days rule working great, but I can't figure out how to make it delete anything older than 7 days. I'm assuming that robocopy isn't the command to do the delete part but I am unsure. Here is what I have, suggestions?

robocopy.exe E:\Backup\PC1 \\PC2\share\TEST /MAXAGE:7
 
Test this first on a safe directory structure to be sure, but I think that you can use the /MIR switch along with your /MAXAGE to do what you want.

Code:
robocopy.exe E:\Backup\PC1 \\PC2\share\TEST /MIR /MAXAGE:7
 
Thanks that helped but wasn't exacly what I was looking for.. I just used that switch then had robocopy move the files out of the orginal folder that was minage:7, then delete the folder the files moved too.. worked great, thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top