使用.bat文件复制具有\ .. \和\ =名称的文件夹的命令

时间:2016-04-25 02:36:18

标签: batch-file copy xcopy

我在谷歌的各个地方搜索,似乎没有任何解决方案。 Xcopy,copy,robocopy,通过变量,通配符解析为文字字符串..

copy C:\soulworker\datas\bin\Table\nf2\data12.v   C:\soulworker\datas\=true_english\

for /R C:\soulworker\datas\bin\Table\nf2\English\ %%f in (*.res) do copy %%f  C:\soulworker\datas\bin\Table\nf2\data12.zip\..\bin\Table\

1 个答案:

答案 0 :(得分:1)

On = Equals Sign in path or file name, read cmd Syntax: Escape Characters, Delimiters and Quotes:

Delimiters

Delimiters separate one parameter from the next - they split the command line up into words.

Parameters are most often separated by spaces, but any of the following are also valid delimiters:

  • Comma (,)
  • Semicolon (;)
  • Equals (=)
  • Space ( )
  • Tab ( )

To keep a delimiter in file or path name, use double quotes as follows:

copy C:\soulworker\datas\bin\Table\nf2\data12.v "C:\soulworker\datas\=true_english\"

On using .. doubled Full Stop, read Naming Files, Paths, and Namespaces:

Use two consecutive periods (..) as a directory component in a path to represent the parent of the current directory.

For instance, all

dir C:\soulworker\datas\bin\Table\nf2\data12.zip\..\bin\Table\
dir C:\soulworker\datas\bin\Table\nf2\data12Xzip\..\bin\Table\
dir C:\soulworker\datas\bin\Table\nf2\foobar.exe\..\bin\Table\
dir C:\soulworker\datas\bin\Table\nf2\foobarABCD\..\bin\Table\    

would resolve to

dir C:\soulworker\datas\bin\Table\nf2\bin\Table\

even if skipped directory component in a path contains inadmissible characters e.g. * (asterisk), ? (question mark) or : (colon), see next example:

==> dir /B /S c:\windows\foo***...???:::\..\system32\notepad.exe
c:\windows\system32\notepad.exe

==>

The \foo***...???::: path part (preceding \..) is not parsed at all…