Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to mirror a folder, but only delete files in the destination folder older than 7 days.

Situation:

  • Folder A is mirrored to Folder B.
  • A file from Folder A is deleted

I would like for that file to remain in Folder B for 7 days. After 7 days the file would be deleted if it still does not exist in Folder A.

Current solution – in a batch file:

  • Use robocopy with the /mir and /xx option to mirror Folder A to Folder B each day
  • Use Delage32 to delete files and empty folders older than 7 days.

The problem is files (those I want to keep) are constantly being deleted and rewritten daily.

Is there a way to have the mirroring process look for extra files in the destination directory, and only delete them if they are older than 7 days? I would like to eliminate delage32.

share|improve this question
add comment

migrated from stackoverflow.com Dec 16 '12 at 19:07

This question came from our site for professional and enthusiast programmers.

1 Answer

I suggest find on Linux and find's -mtime options.

share|improve this answer
    
Thanks for the response. I've used Linux a bit, but currently use Windows 7. Any methods for Windows? –  user1905482 Dec 16 '12 at 3:49
    
This really beongs in serverfault.com in many ways. Look at Powershell. Umm....remembering spell: gci . -Recurse -name –  ArrowInTree Dec 16 '12 at 3:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.