【问题标题】:Copy all folders from a specific direcory into multiple subdirectories using for loop使用 for 循环将特定目录中的所有文件夹复制到多个子目录中
【发布时间】:2014-12-07 17:56:24
【问题描述】:

基本上我想复制Test下的所有内容

Test-> Folders 1,2,3,4,5

进入目标文件夹的每个子目录

Test2 -> Folder A, B, C

这将有效地创建以下内容

Test2 -> A -> 1,2,3,4,5
Test2 -> B -> 1,2,3,4,5
Test2 -> C -> 1,2,3,4,5

这是我试过的代码,显然没有用:)

For %%a in ("C:\Users\helix\Desktop\test") do (for %%b in ("C:\Users\helix\Desktop\test2") do xcopy /s /d /e "%%~a" "%%~b")

【问题讨论】:

    标签: windows command-line command command-prompt


    【解决方案1】:
    @echo off
        setlocal enableextensions disabledelayedexpansion
    
        set "source=c:\users\helix\desktop\test"
        set "target=c:\users\helix\desktop\test2"
    
        for /d %%a in ("%target%\*") do xcopy /s /d /e "%source%\*" "%%~fa" 
    

    对于目标中的每个文件夹,将源复制到选定的文件夹中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-10
      • 1970-01-01
      • 2019-12-08
      • 2019-11-01
      • 1970-01-01
      • 2022-01-19
      • 2017-08-14
      • 2021-02-08
      相关资源
      最近更新 更多