In theory, using /DCOPY:T
should solve all your problems.
But, I've seen this happen, and I'm not sure I'd call it a "bug", but rather a consequence of the sequence of operations (OK, bug).
This command should work to copy all files from C:\Brushes
to D:\NEWBrushes
, and /DCOPY:T
should cause the timestamps of the source folder to be copied to the destination folder:
robocopy "C:\Brushes" "D:\NEWBrushes" /COPY:DAT /DCOPY:T
What I've seen (at least on some versions of Robocopy) is that the command succeeds, but the timestamp of the D:\NEWBrushes
folder is set to the current date and time.
So it appears that the /DCOPY:T
feature does not work for the "base" (topmost) folder you are copying.
I believe that it is working, but that the timestamp of the destination folder is being "stepped on" by operations that are later in the operation sequence.
What I believe is happening for this command:
robocopy "C:\Brushes" "D:\NEWBrushes" /COPY:DAT /DCOPY:T
is something like this:
- Create folder
D:\NEWBrushes
if it doesn't already exist
- Copy the timestamp from
C:\Brushes
to D:\NEWBrushes
- Copy files and sub folders from
C:\Brushes
to D:\NEWBrushes
It appears that Step 3, the modification of the contents of the folder D:\NEWBrushes
causes the timestamp of D:\NEWBrushes
to change.
For me, the "workaround" has been to run the robocopy
command to copy the files and folders, then run the (same) robocopy
command a second time.
So, the first time you run:
robocopy "C:\Brushes" "D:\NEWBrushes" /COPY:DAT /DCOPY:T
all the files and folders will be copied. Then running it again:
robocopy "C:\Brushes" "D:\NEWBrushes" /COPY:DAT /DCOPY:T
(or)
robocopy "C:\Brushes" "D:\NEWBrushes" /DCOPY:T
The second time robocopy
runs, no files or folders within D:\NEWBrushes
will be modified, and the /DCOPY:T
option will tell robocopy
to copy the timestamp from C:\Brushes
to D:\NEWBrushes
(unless there are folders/files in C:\Brushes
that have changed since the first run of robocopy
).
1This is a flyer, based on my experience with
rsync
, but what if you don't have a trailing slash at the end of your target folder? How about trying to modify the script at command-line level instead of using the GUI? I know for a fact that the command-line tool will do what you need. – None – 2012-01-18T05:07:50.850@Randolph West: presently I don't have a trailing slash at the end of the target folder. I still can't make Robocopy include the source folder and its attributes, etc. in the actual copy job. Any ideas? – ptrcao – 2012-01-28T17:19:17.073
If there is no solution for robocopy, you could have a look at xxcopy (there are freeware and commercial versions).
– harrymc – 2012-01-29T16:16:11.997Yep, I understand completely and have added a working solution below. The real problem is that you have to specify all the files and folders in the root NOT to copy. – opsin – 2012-01-31T00:09:48.140