[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 545
  • Last Modified:

Robocopy file deletion - files 7 days or older

I'm trying to setup a robocopy job that will delete all files on a drive with a modified date of seven or more days and write a log of the deletions.

I'm trying this on Windoed 2003 & Windows 2008

Post an example with the switch definitions.
0
Tony Giangreco
Asked:
Tony Giangreco
  • 2
  • 2
1 Solution
 
Tony GiangrecoAuthor Commented:
This is a real life question.
0
 
Justin OwensITIL Problem ManagerCommented:
On Robocopy, you can use the /move switch to move files and directories rather than copying them (as opposed to /mov, which does not remove emptied directories) thus deleting it from your source.  If starting at a root, you will need to include the /s switch to include sub-directories (excluding empty ones). The /xn switch will exclude files newer that the date listed.  To create a logfile, use the /log: command switch.  Thus:

robocopy <sourceroot> <destination path> *.* /s /move /xn <date> /log:<filename>

Does that make sense?

DrUltima
0
 
Tony GiangrecoAuthor Commented:
Yes that makes sense. is there another utility that works well that might do exactly what I want in an automated manner?
0
 
Justin OwensITIL Problem ManagerCommented:
Not that I am aware of.  In the past, I worked with a DBA who was also very good with VBScript.  He wrote a script which, when ran (from the scheduler), parsed a particular directory, copied everything over xxx days old to an alternate location, and then deleted it out of the source directory, while appending to the log it created.  So, I know it can be done, but I am not a VBScript Expert, by any stretch o the imagination.

DrUltima
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now