Created
January 18, 2013 06:09
-
-
Save zxjinn/4562693 to your computer and use it in GitHub Desktop.
Finds all zip files in the current directory, and its sub-directories, then unzips them into folders in the current directory that are named the same as the zip files and sub-directory names. For example: ./subdir/file.zip -> ./subdir_file/extractedfile. Tested on Ubuntu 12.04 with Unzip 6.00.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Extracts all zipfiles in subdirectories to current directory. | |
for source in $(find . -name "*.zip") | |
do | |
unzip -tq $source | |
retval=$? | |
if [ $retval -eq 0 ] | |
then | |
dest=$(echo $source | sed -e 's|.zip||g' -e 's|/|_|g' -e 's|\._||g') | |
unzip -u $source -d $dest | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment