I have two folders synchronised with robocopy (src and mirror) and I try to not removing files in the mirror before 30 days. I tried with /MINAGE option to say "consider every files older than 30 days" so that it only deletes 30-day old files in the mirror but it seems that it is only acting on available files (not deleted).

robocopy /MIR /MINAGE:30 /SD:src /DD:mirror

So basically, if I create a new file, it will be correctly synced in the mirror (by another robocopy task that doesn't delete files at all); and if the day after I delete it, the file will be deleted in the mirror too when running the previous command. To summarize, I want to delete files deleted in the src folder and older than 30 days in the mirror.

Am I missing something ?

Thank you.


I don't know how to do it with robocopy, but when I wanted to do the same as what you're doing, I put this line in my batch file:

forfiles -p %_BACKUPPATH% -m *.rar -d -3 -c "cmd /c del @path"

A dissection is:

  • forfiles - The program for filtering the files
  • -p %_BACKUPPATH% - -p indicates "path" (mine is %_BACKUPPATH% but you can replace this with a "real" path), otherwise it uses the current directory
  • -m *.rar - filter by filetype .rar, skip this parameter for *.*
  • -d -3 - Only affect files older than 3 days (-3)
  • -c "cmd /c del @path" - anything after the -c is what will be executed for each file it finds, in this case, del.
  • Good to know, but I will delete any file older than 3 days. This in not exactly what I want, I just want to delete files deleted in the src folder since n days. – Julio Guerra Jun 6 '11 at 22:01
  • @Julio - and I take it the /mir switch isn't doing this for you? – Mark Henderson Jun 6 '11 at 22:36
  • No. I synced a new file file first, then I deleted it in the src folder and I ran the previous command with /mir and /minage:30 expecting a "delete files older than 30 days" behavior but it does not. – Julio Guerra Jun 6 '11 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.