Unzip all files in a folder using 7zip in CMD line

前端 未结 1 658
被撕碎了的回忆
被撕碎了的回忆 2021-01-06 18:38

i\'m using these lines to extract all JAR files in a folder, destination can be the same one :

set SEVENZIP_EXE=C:\\Program Files\\7-Zip\\
相关标签:
1条回答
  • 2021-01-06 19:14

    You're running it in a command prompt, not on a batch file. If you're on a prompt, you should only use a single %:

    set INPUT_FOLDER=D:\jar
    
    for /f "tokens=1-2 delims=. " %a in ('dir *.jar /a-d/b') do "%SEVENZIP_EXE%" x -aoa -o"%INPUT_FOLDER%" %a.%b
    

    I also noticed that you didn't set the path to 7-zip's executable properly:

    set SEVENZIP_EXE=C:\Program Files\7-Zip\7z.exe
    

    If it doesn't work perhaps try running it as a batch file

    @echo off
    
    set SEVENZIP_EXE=C:\Program Files\7-Zip\7z.exe
    set INPUT_FOLDER=D:\jar
    
    for /f "tokens=1-2 delims=. " %%a in ('dir *.jar /a-d/b') do "%SEVENZIP_EXE%" x -aoa -o"%INPUT_FOLDER%" %%a.%%b
    
    0 讨论(0)
提交回复
热议问题