Created
July 11, 2010 20:08
-
-
Save xim/471782 to your computer and use it in GitHub Desktop.
Unrar recursively in bash, using evil™
This file contains 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 -xv | |
# ^^ debug, feel free to remove... | |
# Enable evil expansion mode: +([0-9]) | |
shopt -s extglob | |
do_unrar() { | |
rar x "$@" | |
} | |
recurse_rar() { | |
for path in "$@" ; do | |
if test -d "$path" ; then | |
recurse_rar "$path"/* | |
elif test -z "${path##*.part+([0-9]).rar}" ;then | |
test "${path##*.part*(0)1.rar}" || do_unrar "$path" | |
elif test -z "${path##*.rar}" ;then | |
do_unrar "$path" | |
fi | |
done | |
} | |
recurse_rar "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment