Created
October 24, 2012 15:29
-
-
Save powerswitch/3946752 to your computer and use it in GitHub Desktop.
Extracts all *.zip files in the directory even with wide-chars in it
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 | |
mkdir "zip" | |
for f in *.zip | |
do | |
if unzip -q -u -d "${f%.zip}" "$f" ; then | |
mv "$f" "zip/$f" | |
else | |
a=true | |
unzip -Z -1 "$f" | egrep -v "^([-_\.:a-zA-Z0-9\t/, ])*\$" | while read var ; do | |
fn=$(echo "$var" | LANG=C sed "s#[^-_\.:a-zA-Z0-9\t]#_#g") | |
fn="${f%.zip}/$fn" | |
unzip -p "$f" "$(echo "$var" | LANG=C sed "s#[^-_\.:a-zA-Z0-9\t/, ]#*#g")" > $fn || a=false | |
done | |
$a && mv "$f" "zip/$f" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment