A simple shell script to recursively extract nested zip files (zip files inside zip files), extracts each zip file to a folder with same name at the location of the zip file and retaining directory structure.
Example:
a.zip
|-1.zip
| |-baz.mp3
|-foo.txt
|-bar.jpg
b.zip
|-2.zip
| |-hello.txt
|-world.txt
After extraction will become:
a
|-1
| |-baz.mp3
|-foo.txt
|-bar.jpg
b
|-2
| |-hello.txt
|-world.txt
The script loop through all zip files, extracting them into a folder with the name of the zip file, then delete the zip file.
Note this may not work well with paths with special characters. Also this script delete each zip file once it’s successfully unzipped. If this behavior is undesirable change the rm
command to a mv
command.
Add -o
option to unzip
command to overwrite existing files.