RoboCopy - Files starting with a dash result in error

假如想象 提交于 2019-12-01 23:33:39

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!