Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I recursively extract zip files on Windows? Each zip file should be unzipped in a new subdirectory, and the zip file should be deleted afterwards.

Each existing or created directory should be scanned for further existing zip files, and so forth.

So the problem is, that I have a huge zip file, which contains many directories with perhaps many further zip files. The original zip files should simply be freed from any zip files, the originial directory tree should be kept, with the convention that each zip file should be represented as a own directory.

So the logic behind is: unzip file in a directory and delete zip file -> go into that directory and unzip all zip files there in the same way -> go into every exisiting subdirectory of the directory and do the same -> and so on recursively

Rough proposal for a recursively programmed batch script file:


  for %%file (%%directory/*.zip) do (unzip %%file | del %%file)

  for /d %%directory (*) do ( call unzip_folder(%%directory) )

share|improve this question
unzipping a zipped file will automatically recurse into the folders within the zip file. Then you can delete it. Could you edit and add more detail about what you want as it seems likely there is more to it than your description. – Paul May 8 '12 at 10:28
It doesn't cover deletion, but check out for at least the recursive unzip scripts. – Pat Sep 13 '13 at 17:04

ExtractNow does this. See Beware that Chrome and maybe other browsers flag the app as malware/spyware. The author maintains that this is just from the installer and points to a portable version for those who don't want the installer (although Chrome also calls that zip file malicious).

share|improve this answer
ExtractNow wasn't able to extract all of the zip folders, so I ended up writing a batch script that works better (for me anyway). It's in my answer. – Pat Sep 19 '13 at 21:30

This ought to work for you (works for me). Just be aware that if there are any other folders, it will recurse through them and unzip everything possible. My recommendation: put your zip file in a dir by itself (and this batch file) before running.

:: To actually include the path expansion character (tilde), I had to give valid numbers; see for bug reference. Also, try call /? for more info.
@REM The %~n0 extracts the name sans extension to use as output folder. If you need full paths, use "%~dpn0". The -y forces overwriting by saying yes to everything. Or use -aoa to overwrite.
@REM Using `x` instead of `e` maintains dir structure (usually what we want)

:: If you want recursive, use FOR /R
@FOR /R %%a IN (*.zip) DO @(
    @if [%1] EQU [/y] (
        @7z x "%%a" -o"%%~dpna" -aoa
    ) else if [%1] EQU [/yd] (
        @7z x "%%a" -o"%%~dpna" -aoa
        @if errorlevel 1 (
            @echo There was an error so I won't delete
        ) else (
            REM You can also prompt with del /p
            @del "%%a"
    ) else (
        @echo 7z x "%%a" -o"%%~dpna" -aoa

@echo USAGE: Use /y to actually do the extraction. Use /yd to extract then delete the zip file.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .