In my C# application, I am using robocopy for with option /s
for copying sub folders also.
Suppose I have files & folders from the last month.
Which file will it copy first, the latest one or the older one?
Is there any way that we can specify that it should copy the old file first or vice versa?
Best Answer
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: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:
If you want more control than that, you can combine the 2 options. For example:
Here are the Robocopy command lines for this (second) example:
If you want to see the order that Robocopy will use to copy the files, you could use the
/L
option:With the
/L
option, Robocopy will just list the files that "would" be copied, but will not actually copy any files.