问题
i'm using these lines to extract all JAR files in a folder, destination can be the same one :
<b>set SEVENZIP_EXE=C:\Program Files\7-Zip\<br>
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
But all what i got is : %%a was unexpected at this time. !!
any suggestion ?
Thanks
回答1:
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
来源:https://stackoverflow.com/questions/18984789/unzip-all-files-in-a-folder-using-7zip-in-cmd-line