如何将文件夹与另一个文件夹合并(包含其中的所有内容)

Aja*_*jay 0 batch-file

我想知道如何将文件夹复制到批处理文件中的另一个文件夹.我希望覆盖同名的东西.谢谢.

Luc*_*oon 9

除非我遗漏了一些东西,最简单的方法是使用xcopy(假设你在Windows上实际上是指.bat文件):

xcopy <SOURCE> <DEST> /e /d /y /h /r /c
Run Code Online (Sandbox Code Playgroud)

解释这些标志:

/e: Include directories and sub directories even if empty
/d: Only copy files which have changed on SOURCE more recently than DEST
/y: Suppress prompts
/h: Also copy hidden and system files
/r: Override read-only files (e.g. ignore Read Only flag)
/c: Continue even if there are errors
Run Code Online (Sandbox Code Playgroud)

来源:我的标准备份脚本,每天运行6年.