在路径中有空格的FORFILES

Raf*_*aeu 5 batch-file

我试图在dos中运行此命令

FORFILES with params /P C:\Builds\ /M *.chm /S /C "cmd /c copy @file C:\My Brand\"
Run Code Online (Sandbox Code Playgroud)

它爆炸,因为目标文件夹路径中有一个空格.如何传递由""分隔的源和目标路径?我尝试添加一个额外的双引号,我得到"命令不被识别"

fox*_*ive 6

0x22 是双引号的表示(十六进制编码).

FORFILES /P C:\Builds\ /M *.chm /S /C "cmd /c copy @file 0x22C:\My Brand\0x22"
Run Code Online (Sandbox Code Playgroud)


Laf*_*ica 5

使用反斜杠转义目标路径周围的引号:

FORFILES /P C:\Builds\ /M *.chm /S /C "cmd /c copy @file \"C:\My Brand\\""
Run Code Online (Sandbox Code Playgroud)