0

I am trying to create a robocopy program which runs every Sunday and pulls in the last 7 days of folders (and its sub-folders). This is because the folder stores years worth of data so I only want to pull in the new folders. Is there a way to do this? I've been playing around with the max/min age but it's pulling in all folders and isn't limiting it to just the last 7 days.

What I have tried:

robocopy \\server\source \\server\destination /MIR /MAXAGE:7

here you can see it's pulling in files older than maxage 7

I want to run this every Sunday and it be smart enough to pull in the last 7 days.

ZygD
  • 2,459
  • 12
  • 26
  • 43
knowlec
  • 1
  • 1
  • 2
    Does this answer your question? [How to copy only new files AND only those that are modified after a certain date?](https://superuser.com/questions/562375/how-to-copy-only-new-files-and-only-those-that-are-modified-after-a-certain-date) – harrymc Feb 11 '22 at 10:08
  • hi @harrymc, the question you posted is for a static date, im looking for it to work to pull in last 7 days. it seems to work as expected when i run it on my C drive, but when i remote into my windows server and use the server folders, it copies everything over. i cant understand why – knowlec Feb 11 '22 at 10:13
  • so ... where is the code that you are running? it seems likely that the problem is whatever holds the target date info ... but mind reading is not one of my talents. [*grin*] – Lee_Dailey Feb 11 '22 at 11:33
  • hi @Lee_Dailey . not sure what you mean by what code im running? im just inputting the robocopy command line above in powershell on my pc. i assumed the MAXAGE would be dependant on the folder date modified/file date modified? as that is what seems to be the case when i try it on my C drive(which is working). i just cant understand why its not working when i point it to the folder location on the server? – knowlec Feb 11 '22 at 11:38
  • Try removing `/MIR`, like `robocopy \\server\source \\server\destination /S /MAXAGE:7` – Theo Feb 11 '22 at 16:13
  • hi @Theo thanks for your reply, i tried your suggestion, however its still pulling in older files going back to 2016, im not sure why this is. really lost here – knowlec Feb 11 '22 at 16:34
  • 2
    @knowlec - [1] without seeing your code ... how can anyone evaluate your code? the robocopy command you used IS code. [*grin*] ///// [2] if you ONLY have robocopy stuff involved ... please REMOVE the powershell tag since it aint being used. – Lee_Dailey Feb 11 '22 at 19:16
  • 1
    Have a look at the files/subfolders of those folders you are looking at. Could very well be that there is a recent addition/modification in there – Theo Feb 12 '22 at 10:29
  • hi, thanks for your response. i did some digging and i looks like the \MIR command cant be used alongside the\MAXAGE command, would this be right? also when i tested just using the \MAXAGE command, it does not bring in any of my folders, just individual files, would this be correct also? @Theo i had a look at the subbfolders and there are no new files in there, however if the two commands cant be used together and im using the \MIR command in my robocopy, that would make sense as to why its pulling across everything? i suppose im stuck back at the beginning so! :) – knowlec Feb 15 '22 at 08:39
  • Try with added `/XO` switch (eXclude Older files.): `robocopy \\server\source \\server\destination /S /XO /MAXAGE:7` – Theo Feb 18 '22 at 15:54

0 Answers0