troubleshooting Question

Move files older than “x” days, and overwrite if already in destination folder

Avatar of Brendan Ford
Brendan Ford asked on
Microsoft DOSWindows Batch
7 Comments2 Solutions2289 ViewsLast Modified:
I mange a bunch of daily generated files for our company, which has many properties, and I am having trouble with my script.  Here is our workflow; each property copies their files to a company folder in their property sub-folder.  Then every week I run a script to move all files that are older than 10days to a subfolder for the year.  
Folder structure = \\server\company\property\year\
Here is my problem, if I use robocopy, and if the a copy of the file in the “property” and the “year” it doesn’t move it and the property folder is not cleaned up.
If I use xcopy I can use the “/Y” switch and the file in the “year” folder will be overwritten, but I can’t find a switch in xcopy that only moves files that “x” days old.

Here is what I have tried:
Using robocopy I tried /is (/IS = Include Same, overwrite files even if they are already the same.) switch and that doesn’t work.

Using xcopy I tried /d:08/19/2016 (/d:date = Copies files changed on or after the specified date) and that doesn’t work because I am looking for before that date note after.

So in short I am looking for either a “xcopy” or “robocopy” script that’s moves files that are 10days old or older from “property” to “year”, and if there is a copy of the file already in the “year” folder overwrite it.

Any help would be great.
Lionel MM
Small Business IT Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros