Recursive Unzipping with 7z.exe

SparkyNZ picture SparkyNZ · Jan 23, 2012 · Viewed 18.6k times · Source

I stumbled across the below line as a means of extracting every .zip file in every subfolder.

FOR /F "usebackq" %a in (`DIR /s /b *.zip`) do 7z.exe e %a

I've tried this on a WinXP cmd.exe prompt and I get the error:

"a was unexpected at this time."

Can somebody please tell me whats wrong with the above line. Is this a 7z.exe error or is there something wrong with the batch script syntax. I did cut and paste this into a .bat file.

Cheers

Answer

Marco picture Marco · Jan 23, 2012

Try to change %a with %%a:

FOR /F "usebackq" %%a in (`DIR /s /b *.zip`) do 7z.exe e %%a