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).
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. – Jan 18 '12 at 05:07