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.
LVL 25
Tony GiangrecoAsked:
Who is Participating?
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.