【问题标题】:Copy a directory with all its content to another directory in batch将一个目录及其所有内容批量复制到另一个目录
【发布时间】:2020-09-06 04:13:02
【问题描述】:

我正在尝试使用批处理将整个目录复制到另一个位置,但我只能复制目录的内容,而不是整个文件夹本身。

有人可以帮帮我吗?

目标: 复制 H:\source 到 C:\target

看起来像:

C:\目标\源\

地点:

source\    
 -> file.txt    
 -> file2.txt    
 -> folder2\
    -> file3.txt

谢谢

【问题讨论】:

    标签: batch-file copy


    【解决方案1】:

    我将提供两种可能的单一命令选项。

    首先是使用命令,(现已弃用)

    %__AppDir__%xcopy.exe "H:\source" "C:\target\source\" /EHRKY
    

    第二个使用 命令,它取代了它:

    %__AppDir__%Robocopy.exe "H:\source" "C:\target\source" /E
    

    在这两种情况下,如果目标目录不存在,则会创建它。

    要了解每个命令的可用选项,请打开命令提示符窗口,然后键入以下内容,然后按 ENTER 键。
    help xcopy
    help robocopy

    【讨论】:

      【解决方案2】:

      使用 xcopy...

      xcopy /h /e /y H:\source c:\target\
      

      选项...

      /h: Copies hidden and system files.
      /e: Copies directories and subdirectories.
      /y: Suppresses prompting to confirm you want to overwrite an existing destination file.
      

      【讨论】:

      • 谢谢!虽然它只是将文件从 source\ 复制到 target\ 并且我需要将整个 source\ 目录复制到 target\ 目录,但它会有所帮助。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多