Reputation: 503
So, I am trying to write a script that uses 7-zip to extract a .zip file containing another .zip file into the current directory and delete it.
Everything works fine when I type it into the command prompt:
set 7ZIP="C:\Program Files\7-Zip\7zG.exe"
for %X in (*.zip) do start "Extracting..." /WAIT %7ZIP% x "%X" && del "%X"
However, when I try to do this in a .bat file (note the %%), I get a strange error
set 7ZIP="C:\Program Files\7-Zip\7zG.exe"
for %%X in (*.zip) do start "Extracting..." /WAIT %7ZIP% x "%%X" && del "%%X"
Any ideas?
Upvotes: 4
Views: 471
Reputation: 503
Okay, I just learned that you apparently can't have variables starting with numbers in .bat scripts (or the start command??), because this works:
set ZIP7="C:\Program Files\7-Zip\7zG.exe"
for %%X in (*.zip) do start "Extracting..." /WAIT %ZIP7% x "%%X" && del "%%X"
Upvotes: 4