且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

批量解压缩并重命名文件(Windows)

更新时间:2023-12-05 20:53:16

  • 迭代html文件的for循环变量是 %% f 而不是 %% I .
  • 您还需要已延迟扩展设置并使用(代码块中)变量.
  • 修饰符〜na 将返回名称和属性?
    • The for loop variable iterating the html files is %%f not %%I.
    • You would also need delayed expansion setting and using a variable in a (code block).
    • The modfiers ~na will return name and attributes?
@Echo off
cd C:\Users\MyUser\Desktop
for /F %%I IN ('dir /b /s *.zip *.rar') DO (
     "C:\Program Files\7-Zip\7z.exe" x -o"%%~dpI" "%%I" -aoa
    for /F "delims=" %%f in ('dir /a-d /b *.html') do (
        ren ""%%f" "%%~nI.html"
    ) 
)
DEL *.zip