The short answer is that when robocopy
is copying these folders from one server to another, I suspect that it is seeing the timestamps differently than you expect, so it is deciding that the existing files on the destination are older than the same files on the source. This could be due to differences in the time/timezone/DST settings on the two machines.
When robocopy
analyzes the files before copying, it classifies each file into one of these classes:
Lonely files: exist on source but not destination.
Newer files: have Newer timestamp on source, (size and attributes: N/A).
Older files: have Older timestamp on source, (size and attributes: N/A).
Changed files: have same timestamp, but different size (attributes: N/A).
Same files: have same timestamp, size, and attributes.
Tweaked files: have same timestamp and size, but different attributes.
Extra files: exist on destination but not source.
Mismatched: is a file on one, and a directory on the other, in source
and destination.
By default (and with the command line options you have given), robocopy
will copy Lonely
, Newer
, and Changed
files. Files in the other classes will not be copied, and will either be simply reported in the output and/or log, or completly ignored.
If robocopy
is copying a file and overwriting an existing file on the destination, then robocopy
thinks that either the timestamo of the source file is before (Newer
) the timestamp of the destination file, or the file sizes are different (Changed
).
In order to tell exactly what's happening to each file, you could run robocopy
with the "/L"
and "/V"
command line options. Using the "/L"
options tells robocopy
to not do any actual copying, and only list what would otherwise be copied. Using the "/V"
options tells robocopy
to to provide Verbose details.
This will show why robocopy
has decided to copy (and skip) each file. So, for example using robocopy
to copy an example fileset.
Here is a listing of the files:
Directory of C:\folder1
02/28/2014 12:48 PM 327 File1.txt
02/28/2014 02:03 PM 333 File2.txt
2 File(s) 660 bytes
Directory of C:\folder2
02/28/2014 12:43 PM 327 File1.txt
02/28/2014 02:03 PM 327 File2.txt
2 File(s) 654 bytes
In this example, the files named File1.txt
, are the same size in the source and destination folders, but has a Newer
timestamp in Folder1
. And, the files named File2.txt
, have the same timestamp in the source and destination folders, but have different (Changed
) file sizes.
Running robocopy
to copy Folder1
to Folder2
, with the "/L"
and "/V"
command line options looks like this.
C:\>robocopy "C:folder1" "c:folder2" /E /L /V
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Fri Feb 28 21:07:29 2014
Source : C:\folder1\
Dest : C:\folder2\
Files : *.*
Options : *.* /V /L /S /E /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
2 C:\folder1\
Newer 327 File1.txt
Changed 333 File2.txt
------------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 1 0 0 0
Files : 2 2 0 0 0 0
Bytes : 660 660 0 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00
Ended : Fri Feb 28 21:07:29 2014
If you run robocopy
with the "/L"
and "/V"
command line options on your set of files, it should give you the information of why robocopy
is unexpectedly copying these files.
I suspect that robocopy
is seeing the timestamps differently than you expect, and is deciding that the files on the source are Newer
than the same existing files on the destination. This could be due to differences in the time/timezone/DST settings on the two machines.
For operations like this I tend to use the mirror switch, (/mir), you can duplicate a directory to a second location, when things are moved out of the source they're also deleted from the destination. I realize that may not work in your situation though.
You may just need a way to clean files out of the source directory once they're considered old enough. Would something like a second job running forfiles work for you?
forfiles /d -14 /p C:\myfolder /C "cmd /c del @file"
This will clean out any files older than 14 days.
Best Answer
As nobody has answered this for so long, I thought I'd suggest a couple of things.
If you are using batch scripts, it should not be too difficult to use sed to strip out the unwanted progress information from the log file. I'm not experienced enough with it to give you a solution using it without spending some time on it though.
There is a single .exe file version of
sed
in UnxUtils (with a slightly more up to date version in the update zip).Another option would be to use XXCOPY instead of
Robocopy
. It has a truly ridiculous number of switches (over 230), which allows you to do whatever you want. You have to spend a whole evening choosing which ones you want to use. It also has a GUI progress dialogue box, if you would prefer to use that.There is a free version for personal use, which cannot be used for automated scripting, as you need to interactively follow prompts, unlike the paid-for version.
Another alternative is RichCopy, which has a GUI which would can use to choose your options. It can then give you the command-line of you operation for use in batch scripts.