我具有以下目录结构:
\Users\DorrisPringle\Desktop\test
\Users\DorrisPringle\Desktop\test\mycopy.bat
\Users\DorrisPringle\Desktop\test\backup
\Users\DorrisPringle\Desktop\test\backup\asdf.txt
\Users\DorrisPringle\Desktop\test\backup\a_directory
\Users\DorrisPringle\Desktop\test\backup\a_directory\qwer.txt
如果密钥文件不存在,我想将backup / *复制到目录“ test”中。这是从mycopy.bat执行的:
if exist "\Users\DorrisPringle\Desktop\test\myservice.exe" (
echo "all is good."
) else (
robocopy "\Users\DorrisPringle\Desktop\test\backup" "\Users\DorrisPringle\Desktop\test" /MIR /R:1 /W:2
)
这给了我以下错误,最终只是删除了“ test”目录中的所有内容。我可以使用robocopy
将测试目录中的所有内容复制到备份目录中,但是似乎无法正常工作。
Started : Sunday, July 15, 2018 3:59:19 AM
Source : C:\Users\DorrisPringle\Desktop\test\backup\
Dest : C:\Users\DorrisPringle\Desktop\test\
Files : *.*
Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1 /W:2
------------------------------------------------------------------------------
1 C:\Users\DorrisPringle\Desktop\test\backup\
*EXTRA Dir -1 C:\Users\DorrisPringle\Desktop\test\backup\
*EXTRA File 0 asdf.txt
*EXTRA Dir -1 C:\Users\DorrisPringle\Desktop\test\backup\a_directory\
*EXTRA File 0 qwer.txt
*EXTRA File 177 s.bat
New File 0 asdf.txt
2018/07/15 03:59:19 ERROR 3 (0x00000003) Copying File C:\Users\DorrisPringle\Desktop\test\backup\asdf.txt
The system cannot find the path specified.
答案 0 :(得分:1)
/MIR
开关等效于/E /PURGE
/PURGE
指示robocopy
删除目标(测试目录)中源文件(备份目录)中不存在的所有内容,然后再开始处理文件,但是由于备份目录本身位于目标文件中它也会被删除。
只需将/MIR
替换为/E
开关