5

Robocopy Copy Flags?

I just recently made an answer here https://stackoverflow.com/a/15211788/891976 where I suggested using robocopy and its /copy flags, but for some as of yet unknown reason, the /copy flags are being ignored.

This was originally noted by dbenham, but I too have confirmed that when I specified the /copy:DA flag, robocopy just ignored it and did a full DAT copy.

Robocopy Documentation

Script

@echo off
robocopy Tools Tolls /COPY:DA /S /IS
pause >nul

Output

------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows

------------------------------------------------------------------------------

  Started : Mon Mar 04 16:59:43 2013

   Source : C:\Users\Username\Desktop\Tools\
     Dest : C:\Users\Username\Desktop\Tolls\

    Files : *.*

  Options : *.* /S /COPY:DAT /IS /R:1000000 /W:30

------------------------------------------------------------------------------

          New Dir          5    C:\Users\Username\Desktop\Tools\
100%        New File                 825        Connect.bat
100%        New File                 424        DevSpec.bat
100%        New File                 215        Disconnect.bat
100%        New File               69599        Shortcuts.zip
100%        New File              28.8 m        Tools.zip

------------------------------------------------------------------------------

               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :         1         1         0         0         0         0
   Files :         5         5         0         0         0         0
   Bytes :   28.87 m   28.87 m         0         0         0         0
   Times :   0:00:00   0:00:00                       0:00:00   0:00:00


   Speed :           150632582 Bytes/sec.
   Speed :            8619.265 MegaBytes/min.

   Ended : Mon Mar 04 16:59:43 2013

Anyone have insight into why the /copy flag did not work?

11
  • What timestamp should robocopy use if you don't specify the T flag?
    – AbqBill
    Mar 4, 2013 at 23:13
  • 1
    @AbqBill - The assumption would be the current system timestamp.
    – dbenham
    Mar 4, 2013 at 23:16
  • @AbqBill I am just making an assumption since the functionality appears to be undocumented, but if you do not copy the time stamps, then it would seem to make sense to use the current time. However, I am unable to even verify this since it is ignoring my /copy flags. Mar 4, 2013 at 23:17
  • I don't know the answer, but my guess is that it assumes T if you specify A or D. Experiment and see.
    – AbqBill
    Mar 4, 2013 at 23:23
  • 2
    @AbqBill Side-Effect or not it is undocumented behavior since the documentation gives all indication that this is a valid use case. Therefore, it could also be classified as a bug in design. For it supports a DA option for the DCOPY but not the COPY. That is a very inconsistent implementation, that has a need to be documented. Mar 5, 2013 at 2:52

2 Answers 2

3

Undocumented Behavior

Well it would appear the undocumented behavior is as follows:

Whenever, the D flag is used for /COPY, robocopy will automatically add the T flag.

However, this does not apply to the directory /DCOPY flag. It can be specified without T and work.

Tested (no files are copied without D, only folders)

/Copy:D becomes /Copy:DT
/Copy:A becomes /DCopy:DA /Copy:A
/Copy:T becomes /DCopy:D /Copy:T
/Copy:DT becomes /DCopy:D /Copy:DT
/Copy:AT becomes /DCopy:DA /Copy:AT

Note: tested on Windows 7 64 bit and Windows 8 64 bit.

7
  • How would you specify /DCOPY without including T, and what would it mean? The only (documented) valid option to /DCOPY is T (so only /DCOPY:T). See the Command line reference here: Updated: April 17, 2012. Particularly the D option seems meaningless with /DCOPY... how would (should) the behavior of /DCOPY:DT be different than /DCOPY:T? May 22, 2013 at 11:11
  • ...Well it would appear the undocumented behavior is as follows... this is documented behavior. See the documentation here: XP010 May 22, 2013 at 11:24
  • I'm curious, Is this document still provided by an official Microsoft source? Also this document is about 17 version / 10 years old. Yet, the behavior is still undocumented in all the current official documentation. May 22, 2013 at 21:41
  • '... Is this document still provided by an official Microsoft source?' Yes, while 10 years old, it is the most current full official Microsoft documentation available for Robocopy. It is currently available as Robocopy.doc for XP010 version when you download the current version of Robocopy GUI. (Note: Robocopy GUI includes version XP026 of Robocopy.exe and version XP010 of Robocopy.doc). May 24, 2013 at 6:01
  • 1
    @KevinFegan Something to note, it would seem that Microsoft has dropped the XP0## version notation. On Windows 8.1, I only see 6.3.9600.17415 as both the File and Product version. Apr 27, 2015 at 14:35
2

This is by design, and also it is not undocumented.

According to the Robocopy Documentation:

Note: If file Data is copied, then file Timestamps are also copied.

This is from page 6 in this document: XP010


About the XP010 document linked above:

While 10 years old, as of the date of this posting, it is the most current full official Microsoft documentation available for Robocopy. It is currently available as Robocopy.doc for XP010 version when you download the current version of Robocopy GUI from Microsoft website. (Note: Robocopy GUI includes version XP026 of Robocopy.exe and version XP010 of Robocopy.doc).

As of the date of this posting, no (printed or electronic/downloadable) full official Microsoft documentation is available for Robocopy version XP026 or XP027.

4
  • Interesting, So the only mention of it is in a document from 2003 for version XP010. But it is undocumented in all current official documentation. Windows 7 Version = XP027. May 22, 2013 at 21:35
  • 1
    '...this document is about 17 version old...' actually 2 versions old. After XP010 was version XP026 then XP027. The document I linked, while 10 years old, is the most current full official Microsoft documentation available for Robocopy. May 24, 2013 at 1:10
  • 1
    Again, Interesting. The only place where this document was released was through a TechNet blog (November 2006) with the release of a tool "RoboCopy GUI" (Abandonware). And incorrect, that document is not the most current full official Microsoft documentation. This is: technet.microsoft.com/en-us/library/cc733145.aspx or this robocopy /?. Also note that this tool is not by the official robocopy owners but a MSN Search group worker. May 24, 2013 at 17:07
  • @david-ruhmann Interesting - I was not aware of the Robocopy documentation on TechNet. However, it is much less detailed than the XP010 version of the document. The explanation of the commands in XP010 missing from the TechNet document is extremely helpful! Still, I have read that document dozens of times, but never noticed that note on page 6, nor the sentence on page 20: However, if file data is copied, file timestamps are also copied. Nov 22, 2017 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .