且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

批处理文件从一个文件夹复制到另一个文件夹

更新时间:2023-11-27 22:08:52

XCOPY.EXE 绝对是在这里你的朋友。
它内置于Windows,所以它的成本是什么。

xcopy.exe is definitely your friend here. It's built into Windows, so its cost is nothing.

只是 XCOPY /秒C:\\来源D:\\目标

您很可能需要调整一些东西;一些我们还添加选项包括这些:

You'd probably want to tweak a few things; some of the options we also add include these:


  • / S / E - 递归复制,包括复制空目录

  • / V - 添加此验证与原始副本。慢,但对于偏执。

  • / H - 副本系统和隐藏文件

  • / K - 复制只读处理文件的属性。否则,所有的文件变成可读写的。

  • / X - 如果你关心的权限,您可能希望 / O / X

  • / Y - 覆盖现​​有文件之前不提示

  • / Z - 如果你想复制可能会失败,并且要重新启动它,使用它。它把对每个文件,因为它拷贝标记,这样你就可以重新运行xcopy命令从停止的地方接了。

  • /s/e - recursive copy, including copying empty directories.
  • /v - add this to verify the copy against the original. slower, but for the paranoid.
  • /h - copy system and hidden files.
  • /k - copy read-only attributes along with files. otherwise, all files become read-write.
  • /x - if you care about permissions, you might want /o or /x.
  • /y - don't prompt before overwriting existing files.
  • /z - if you think the copy might fail and you want to restart it, use this. It places a marker on each file as it copies, so you can rerun the xcopy command to pick up from where it left off.

如果您认为XCOPY可能会失败,中途(当你复制了片状网络连接等),或者你必须停止它,并希望以后继续它,你可以使用 XCOPY / S / ZC:\\来源D:\\目标

If you think the xcopy might fail partway through (like when you are copying over a flaky network connection), or that you have to stop it and want to continue it later, you can use xcopy /s/z c:\source d:\target.

希望这有助于。