I have numerous zip archives, each of which contains a number of zip archives. What is the best way to recursively extract all files contained within this zip archive and its child zip archives, that aren't zip archives themselves?
|
|
This will extract all the zip files into the current directory, excluding any zipfiles contained within them.
Although this extracts the contents to the current directory, not all files will end up strictly in this directory since the contents may include subdirectories. If you actually wanted all the files strictly in the current directory, you can run
Note: this will clobber files if there are two with the same name in different directories. If you want to recursively extract all the zip files and the zips contained within, the following extracts all the zip files in the current directory and all the zips contained within them to the current directory.
|
||||
|
|
|
As far as I understand, you have zip archives that themselves contain zip archives, and you would like to unzip nested zips whenever one is extracted. Here's a bash 4 script that unzips all zips in the current directory and its subdirectories recursively, removes each zip file after it has been unzipped, and keeps going as long as there are zip files. A zip file in a subdirectory is extracted relative to that subdirectory. Warning: untested, make a backup of the original files before trying it out or replace
The script will also work in zsh if you replace the Here's a portable equivalent. The termination condition is a little complicated because
|
|||
|
|
|
|
|||||||
|
|
The easiest way is to use atool: http://www.nongnu.org/atool/ It is a very good script that use zip, unzip, tar, rar etc. programs to extract any archive. Use |
|||||
|
|
This perl script will extract each .zip file into its own subdirectory. Run the script more than once to handle nested zip files. It does not delete .zip files after extraction but you could make that change by adding an unlink() call.
|
||||
|
|
|
You'll want to be careful automatically unzipping zip files inside of zip files: http://research.swtch.com/2010/03/zip-files-all-way-down.html It's possible to concoct a zip file that produces a zip file as output, which produces a zip file as output, etc etc etc. That is, you can make a zip file that's a fixed oint of "unzip" the program. Also, I seem to recall people making zip files that would "explode", that is a very small zip file would unzip to multi-gigabytes of output. This is a facet of the method of compression. |
|||
|
|
