【问题标题】:Copy the File and Change Name at Same Time by DOS通过 DOS 同时复制文件和更改名称
【发布时间】:2013-03-24 09:45:26
【问题描述】:

文件位于这样的位置

folderA/aaa.html
folderA/bbb.html

我想将它们复制到 folderB 但不同的位置,比如

folderB/aaa/index.html
folderB/bbb/index.html

我试过了

for /R "C:\...\folderA\" %%f in (*.html) do copy /y "%%f" "%%~nf/index.html"

不工作,因为我没有地方放folderB

请帮忙

【问题讨论】:

    标签: windows for-loop batch-file cmd rename


    【解决方案1】:

    试试这个:

    @echo off &setlocal
    for %%i in (folderA\*.html) do (
        for /f "delims=" %%j in ("%%~dpi.") do (
            md "%%~dpjfolderB\%%~ni"
            copy "%%~fi" "%%~dpjfolderB\%%~ni\index.html"
        )
    )
    

    【讨论】:

    • 非常令人印象深刻。 folderA/aaa/ccc.html 怎么样,我希望它变成folderB/aaa/ccc/index.html 当前解决方案无法处理子目录。顺便说一句,这是什么%%~dpi 东西,有没有参考
    • 您在命令行上获得帮助,请键入help for :)
    猜你喜欢
    • 1970-01-01
    • 2022-12-16
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-02
    相关资源
    最近更新 更多