xcopy和robocopy之间的区别

我是批处理脚本的新手。 作为一个新手,我发现他们两个都有用,而脚本xcopy和robocopy之间的主要区别是什么?

Solutions Collecting From Web of "xcopy和robocopy之间的区别"

Robocopy替换了较新版本的Windows中的XCopy

  1. 使用镜像,XCopy不
  2. 有一个/ RH选项允许运行副本的设置时间
  3. 有一个/ MON:n选项来检查文件的差异
  4. 拷贝比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开关让你改变这种行为。

  • 用/ R你可以告诉它多少次重试,
  • / W让你指定重试之前的等待时间。

如果有办法在这里添加文件,我可以分享我的结果。

  • 我的测试全部在同一台计算机上完成
  • 从一个外部驱动器复制文件到另一个外部,
  • 在USB 3.0端口上。

我还在我的测试中包含了FastCopy和Windows Copy,每个测试都运行了10次。 请注意,差异是非常显着的。 95%置信区间没有重叠。

他们都是垃圾! XCOPY年龄较大,不可靠,所以微软用ROBOCOPY取而代之,这仍然是垃圾。

http://answers.microsoft.com/en-us/windows/forum/windows_8-files/robocopy-appears-to-be-broken-in-windows-8/9a7634c4-3a9d-4f2d-97ae-093002a638a9

不要担心,这是一个由原来的COPY命令启动的一个长期的传统,直到今天,仍然需要/B开关才能真正地复制它!