【问题标题】:Windows Batch file; find specific file type and copy to a folder keeping the relative folder structureWindows 批处理文件;查找特定文件类型并复制到保持相对文件夹结构的文件夹
【发布时间】:2012-10-04 23:19:55
【问题描述】:

我想编写一个 Windows 批处理文件,它可以递归查找所有 *.txt 文件并复制到目标目录,但保留相关目录结构。

例如

/examples
    /a
        /data
            a.txt
            b.txt
        /source
            a.js
            b.js
    /b
       /data
            c.txt
            d.txt
       /images
            a.png

复制到testCopy文件夹

/textCopy
    /a
        /data
            a.txt
            b.txt

    /b
       /data
            c.txt
            d.txt

我当前的 Windows 环境是 XP,我将无法使用 Robocopy。

【问题讨论】:

    标签: windows batch-file


    【解决方案1】:
    xcopy /s examples\*.txt textCopy\
    

    【讨论】:

    • 如何知道文件夹是否包含 *.txt 文件。
    • @user1721547 - /S 选项不会创建空文件夹。通过在命令行中键入 HELP XCOPY 来阅读可用的文档。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多