Avatar of Brendan Ford
Brendan Ford

asked on 

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

Hello
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.
Microsoft DOSWindows Batch

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon