RoboCopy - Files starting with a dash result in error

前端 未结 1 1928
栀梦
栀梦 2021-01-20 14:47

We are in the process of migrating files from one share to another. We have built a tool in which the user can select directories and/or individual files to be copied to a d

1条回答
  •  孤城傲影
    2021-01-20 15:15

    This appears to be a bug in robocopy; it has some other known similar ones:

    https://support.microsoft.com/en-us/kb/2646454

    Here's a possible workaround:

    robocopy c:\temp c:\temp2 *-a.txt /xf *?-a.txt
    

    *-a.txt will still match "-a.txt", but it also matches "x-a.txt", "xx-a.txt", etc.

    The /xf file exclusion knocks out "x-a.txt", "xx-a.txt", and any other file with characters (specifically, at least one character) in front of the hyphen.

    I've confirmed that the above command will match only "-a.txt" even if c:\temp also contains these files:

    other folder\-a.txt
    -a.txt1
    -a1.txt
    x-a.txt
    xx-a.txt
    

    I'm not 100% confident though, so you might want to think up some other filenames to test that against.

    0 讨论(0)
提交回复
热议问题