Extract recursively using 7-Zip

7

3

I have several folders, and within each folder, there are ZIP files. I want to run a command line order to recursively go through every folder and extract in place every archived file that it finds, then move on to the next folder. Is this even possible?

newyuppie

Posted 2011-02-21T02:33:32.717

Reputation: 207

What should it do if there are multiple ZIP files in the same folder? Should it extract them into subfolders or extract their contents into the same folder (as the ZIP files), and if so, should it overwrite or ignore dupliates? – Synetech – 2011-02-21T02:38:40.047

What OS are you using? – Paused until further notice. – 2011-02-21T02:39:03.150

The best way to do this might be to write a little script to do it. What Operating System are you on? – Leif – 2011-02-21T02:41:42.570

1Actually, no script is necessary, it should be doable with a single FOR command; the specific 7-zip options depend on the requirements. – Synetech – 2011-02-21T02:50:23.433

Answers

9

If you are using Linux, you can use

find -iname \*.zip -exec unzip {} \;

(after installing unzip)

In Windows, you can use

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

Assuming that you have 7z.exe in your PATH. Run that command in folder where you want to (recursively) unzip all zip files.

Olli

Posted 2011-02-21T02:33:32.717

Reputation: 6 704

5

Use the open source Multi Unpacker tool for Windows. It requires you having installed WinRAR, but other than that it's actually pretty versatile...

Multi Unpacker

derio

Posted 2011-02-21T02:33:32.717

Reputation: 151

4

With 7-Zip you can issue the following command to extract all files to your current base folder:

7z e -an -air!*.zip -r

So if you have

.
+ \ folder
    + \ file.zip

the contents of file.zip will end up in . with all archive folders removed.

Or use the x option to extract including the subfolders of the archive.

You may be able to play with the -o option to have each zip file extracted in the subfolder it's in, though I often find I need all files to be put into one location instead.

jessehouwing

Posted 2011-02-21T02:33:32.717

Reputation: 602