【问题标题】:A script that will copy files and move them into another folder将复制文件并将它们移动到另一个文件夹的脚本
【发布时间】:2020-04-30 15:09:33
【问题描述】:

我知道这个问题似乎已经被问了一百万次,但我认为我的困境有点不同,我找不到任何符合我目的的东西。如果这个问题已经被问过,而我只是以某种方式错过了它,请让我参考那个问题。

我有三个文件需要从一个文件夹复制到另一个文件夹,这些文件可能已经存在。

例如,C:\Program Files\file.dll 需要移动到 C:\Program Files (x86)file.dll 可能已经存在。我还需要将源文件保留在其目录中。

我知道MOVE [source][destination] 会从源中移动文件,这将删除它们。

我试过了:

set source=C:\Program Files\file.dll
set destination=C:\Program Files (x86)\
xcopy %source% %destination% /y

我在这里找到的:How do I write a batch script that copies one directory to another, replaces old files?

但我收到消息“参数数量无效”。

我错过了什么愚蠢的东西吗?有没有一种简单的方法可以做到这一点?即使是正确方向的提示也将不胜感激!

【问题讨论】:

    标签: scripting batch-file


    【解决方案1】:

    如果路径中有空格,您可能需要:

    xcopy "%source%" "%destination%" /y
    

    【讨论】:

    • 谢谢,这正是我所缺少的!
    【解决方案2】:

    使用它可以将所有文件从源文件夹复制到目标。

    这也可以在您的给定路径上添加新的洪水泛滥名称或将其复制到现有文件夹。

    powershell Copy-Item -Path "C:Source\floder" -Destination "C:\Destination" -Recurse

    【讨论】:

      猜你喜欢
      • 2016-05-08
      • 1970-01-01
      • 2011-07-29
      • 1970-01-01
      • 2020-07-30
      • 2013-11-20
      • 2015-03-17
      • 1970-01-01
      • 2021-07-20
      相关资源
      最近更新 更多