Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to copy files from one drive to another, but I only want to copy source files that are newer than the destination file. BUT, I also want to only copy source files that have been changed after a certain date.

I know I can use xcopy to do either one of these things, but I would like to do both at the same time.

So for example, I want to copy all source files dated on or after 3/1/2013, but in addition I only want the file copied if the source file is newer than the destination. So ideally I would like to do something like this:

xcopy c:\*.* e:\*.* /D:03-01-2013

combined with something like this:

xcopy c:\*.* e:\*.* /D

Can this be done with xcopy or Robocopy?

share|improve this question
up vote 12 down vote accepted

This will probably get you what you want:

Robocopy c:\ e:\ *.* /MAXAGE:20130301 /XO /E

Add the /L command to this to see what it will do without it actually doing it first just to make sure.

Check here for more information on Robocopy's options.

share|improve this answer

In case someone wants to do the same without command line, the SyncToy tool does the job pretty well.

share|improve this answer

If you simply use xcopy with both options at once it will Just Work, exactly like you would expect:

xcopy c:\*.* e:\*.* /D /D:03-01-2013

That line will copy everything from the c drive onto the e drive, as long as it was modified later than March 3rd 2013 AND the source file is newer than the destination file. Try it out!

share|improve this answer
How would you do it if you wanted the file to be at least 1 hour old? In other words, a relative age from now, not an absolute age? – toddmo Jul 2 '14 at 19:30
@toddmo It looks like both xcopy and Robocopy can only filter by date, not time. You would have to use some other utility, or something like a FOR loop with the DIR /O:D command. – Malcolm Jul 3 '14 at 21:35
RoboCopy can use minage and maxage, but it is only on the day level, not hour. You can also read here for some other tools and batch scripts that will copy files 1 hour old. – Sun Nov 5 '14 at 19:58

This worked for me while addressing a 'similar' problem

xcopy /m "Source" "Dest"
share|improve this answer
How will the /m switch meet the OP's requirement? What does it do? A little more information, please. – Tog Oct 1 '15 at 11:08
This would only work if archive bit is only enabled in those new or modified files within the data range, so it won't do what the OP asked without fiddling first with the archive attribute. – zagrimsan Oct 1 '15 at 12:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .