robocopy invalid parameter “-”

匿名 (未验证) 提交于 2019-12-03 01:36:02

问题:

I am trying to complete my batch script but under certain circumstances it fails.

This is the command I am running:

ROBOCOPY "C:\test\dash2\Hello - 4\" "C:\test\dash2\Hello - 4\..\" /MOV 

And this is the error I am getting

-------------------------------------------------------------------------------    ROBOCOPY     ::     Robust File Copy for Windows  -------------------------------------------------------------------------------    Started : Mon May 11 01:28:46 2015     Source - C:\test\dash2\Hello - 4" C:\test\dash2\Hello\      Dest -      Files :   Options : /COPY:DAT /R:1000000 /W:30  ------------------------------------------------------------------------------  ERROR : Invalid Parameter #2 : "-" 

I do surround my source and destination by double quotes. But according to the ROBOCOPY log the source and dest seems to be wrong

EDIT

It seems that it thinks the space is a separator, so it treats the "-" as the second parameter.

回答1:

ROBOCOPY "C:\test\dash2\Hello - 4\" "C:\test\dash2\Hello - 4\..\" /MOV                                  ^                             ^ 

Remove the ending backslashes that are escaping the quotes

edited to adapt to comments

If source and destination are variables and removing the backslash is a problem, this can be used

robocopy "%source%\." "%target%\." 


回答2:

Well it seems that you have to escape the double quotes. The trick is to only escape the second double quote

So the correct solutions was:

ROBOCOPY "C:\test\dash2\Hello - 4\/" "C:\test\dash2\Hello - 4\..\/" /MOV 


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