Wednesday 1 July 2020

Which file does robocopy copy first?

https://superuser.com/questions/378200/which-file-does-robocopy-copy-first

Which file does robocopy copy first?

 

If you want to copy newer (recent) files first, you could use the Robocopy /MAXAGE:n and /MINAGE:n command line options.
You will have to run Robocopy 2 or more times (depending on how much you want to control the file copy order by the "age" of the files).
Here is information about the /MAXAGE:n and /MINAGE:n command line options:
/MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
/MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
    (If n < 1900 then n = n days, else n = YYYYMMDD date).
In the simplest case for example, you could first copy files that are AT-MOST 1 day old, then when that is finished, copy all files that are AT-LEAST 1 day old. Here are the 2 Robocopy command lines for this (first) example:
First run of Robocopy:
    robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MAXAGE:1
Second run of Robocopy:
    robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MINAGE:1
If you want more control than that, you can combine the 2 options. For example:
  1. First copy all files that are AT-MOST, 1 day old
  2. Then copy files that are AT-LEAST 1 day old, and AT-MOST 2 days old
  3. Then copy files that are AT-LEAST 2 days old, and AT-MOST 3 days old
  4. Then copy files that are AT-LEAST 3 days old, and AT-MOST 5 days old
  5. Then copy files that are AT-LEAST 5 days old (all remaining filea)
Here are the Robocopy command lines for this (second) example:
robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MAXAGE:1
robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MAXAGE:2 /MINAGE:1
robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MAXAGE:3 /MINAGE:2
robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MAXAGE:5 /MINAGE:3
robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MINAGE:5

If you want to see the order that Robocopy will use to copy the files, you could use the /L option:
robocopy "C:\source\path" "C:\dest\path" /S /COPY:DAT /DCOPY:T /MAXAGE:1 /L
With the /L option, Robocopy will just list the files that "would" be copied, but will not actually copy any files.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.