robocopy switch(/xf) 中断脚本

robocopy switch(/xf) breaks script

我有一个使用 robocopy 复制文件的脚本。代码如下。当我添加开关 /xf thumbs.db 时,日志文件指出目标和源未包含并且文件未被复制。

我是不是漏掉了什么?

 SET switch1=/r:30 /w:1 /np /s /mt /log:"F:\Backup.log"

 SET source="\server\folder"
 SET destination="F:\folder"

 FOR  /d %%i IN ("%source%\*") DO ROBOCOPY %switch1% "%%i" "%destination%\%%~nxi"
 FOR /d %%p IN ("%source%\*.*") DO RMDIR "%%p" /s /q
 CD /d %destination%
 FOR /d %%i IN (*.*) DO RD "%%i" > NUL 2>&1

这个是我自己想出来的。这只是语法中错误的位置。我将 %switch1% 移到了行尾,它起作用了。

FOR  /d %%i IN ("%source%\*") DO ROBOCOPY "%%i" "%destination%\%%~nxi" %switch1%