3

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

Mark
  • 3,609
  • 1
  • 22
  • 33
Rami Alshoubaki
  • 67
  • 1
  • 2
  • 10

1 Answers1

3

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
konsolebox
  • 72,135
  • 12
  • 99
  • 105
  • Uhm, what does the `tokens=1-2` do? The `dir` command only returns one item per line using the `/a-d/b` arguments, doesn't it? is the `delims` argument then splitting each line at the dot, and the `tokens` argument tells the command line to return both parts to the `do` instructions as `%a` and `%b`? – Christian Mar 31 '15 at 14:50