我是批处理脚本的新手。 作为一个新手,我发现他们两个都有用,而脚本xcopy和robocopy之间的主要区别是什么?
Robocopy替换了较新版本的Windows中的XCopy
是的,我同意Mark Setchell,他们都是废话。 (由微软提供给你)
更新:
XCopy返回码:
0 - Files were copied without error. 1 - No files were found to copy. 2 - The user pressed CTRL+C to terminate xcopy. enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line. 5 - Disk write error occurred.
Robocopy返回代码:
0 - No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized. 1 - One or more files were copied successfully (that is, new files have arrived). 2 - Some Extra files or directories were detected. No files were copied Examine the output log for details. 3 - (2+1) Some files were copied. Additional files were present. No failure was encountered. 4 - Some Mismatched files or directories were detected. Examine the output log. Some housekeeping may be needed. 5 - (4+1) Some files were copied. Some files were mismatched. No failure was encountered. 6 - (4+2) Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory 7 - (4+1+2) Files were copied, a file mismatch was present, and additional files were present. 8 - Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. 16 - Serious error. Robocopy did not copy any files. Either a usage error or an error due to insufficient access privileges on the source or destination directories.
有关Robocopy返回值的详细信息,请参阅http://ss64.com/nt/robocopy-exit.html
最重要的区别是, robocopy
会(通常)发生错误时重试,而xcopy
不会。 在大多数情况下,这使得robocopy
更适合在脚本中使用。
我可以看到的差异是Robocopy有更多的选择,但是除非我做一些特别的事情,否则我没有发现它们中的任何一个特别有用。
我做了几个复制例程的基准测试,发现XCOPY和ROBOCOPY是最快的,但令我惊讶的是,XCOPY一直淘汰了Robocopy。
robocopy重试一个失败的副本是很有讽刺意味的,但是在我的基准测试中,xcopy从来没有做过这个测试。
我做了完整的文件(逐字节)文件比较后,我的基准测试。
以下是我在测试中用于robocopy的开关:
**"/E /R:1 /W:1 /NP /NFL /NDL"**.
如果有人知道更快的组合(除了删除/ E,我需要),我很乐意听到。
robocopy另一个有趣的/令人失望的事情是,如果一个副本确实失败了,默认情况下它会在每次尝试之间延迟30秒重试1000000次。 如果你在无人看管的情况下运行一个很长的批处理文件,当你几个小时后回来发现它仍然试图复制一个特定的文件时,你可能会感到非常失望。
/ R和/ W开关让你改变这种行为。
如果有办法在这里添加文件,我可以分享我的结果。
我还在我的测试中包含了FastCopy和Windows Copy,每个测试都运行了10次。 请注意,差异是非常显着的。 95%置信区间没有重叠。
他们都是垃圾! XCOPY
年龄较大,不可靠,所以微软用ROBOCOPY
取而代之,这仍然是垃圾。
不要担心,这是一个由原来的COPY
命令启动的一个长期的传统,直到今天,仍然需要/B
开关才能真正地复制它!