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 easily copy a batch of files from one very big directory to another based on the hour of creation (every hour i want to copy the files from last hour).

I have used Xcopy /D function but you can only put the date but not the hour.

Is there another command? the directory is really big and it's very long to test each file for it's creation date in a Script. Xcopy is great but lacks the hour.

share|improve this question
up vote 5 down vote accepted

Robocopy will do the job, assuming you can specify a file from the previous hour's copy as a timestamp -- something like

robocopy <source> <destination> * /XO <file-from-an-hour-ago> <filespec-to-copy>

should do the trick, with a bit of tweaking. Hope this helps!

Edited to add: On a pre-Vista box you may need to download Robocopy, which as far as I know is best obtained in the Server 2003 Resource Kit Tools download; as far as I'm aware, Vista and newer should have Robocopy installed by default and present in your path.

share|improve this answer
Hi, i have created a file but when i do your command, robocopy will download everything, not only the files older than the file i have created.. Are your sure /XO takes a file as parameter ? – Fredv Oct 3 '12 at 6:05
I am, but I did leave out an argument in the robocopy command; the <source> and <destination> args are directory paths, and the final argument needs to be a filespec matching those files you want to copy ("*" will probably do, given the /XO filter.) Tested and confirmed working as intended. – Aaron Miller Oct 4 '12 at 12:24
@Fredv Hey, if it solved your problem or pointed you in the right direction, would you mind accepting my answer so I get the rep bonus? Thanks! – Aaron Miller Dec 20 '12 at 16:53

You must log in to answer this question.

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