Created
October 15, 2012 12:41
-
-
Save frah/3892253 to your computer and use it in GitHub Desktop.
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 | |
set -e | |
echo "## Unrar archive ##" | |
for f in $(find . -maxdepth 1 -type f -name "*.rar"); do | |
echo " - $f" | |
unrar x -o- -p- -xshareraws.blogspot.com.url -y -inul $f | |
done | |
echo "## Deflate files ##" | |
#find . -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 -i zip -r "`basename {}`".zip "{}" | |
for d in $(find . -maxdepth 1 -mindepth 1 -type d); do | |
i=0 | |
for f in $(find $d -maxdepth 1 -mindepth 1 -type f); do | |
mv $f ${f%/*}/$(printf "%05d" $i)${f##*.} | |
i=$((i+1)) | |
done | |
zip -qmr $d.zip $d -x \*.db \*.lnk \*.html \*.htm | |
done | |
echo "## Make folder ##" | |
for f in *.zip; do | |
DIRNAME=$(expr "$f" : "\(.*\) .[0-9][0-9]") | |
if [[ $DIRNAME != "" ]]; then | |
if [[ ! -d "$DIRNAME" ]]; then | |
mkdir "$DIRNAME" | |
fi | |
mv "$f" "$DIRNAME/" | |
fi | |
done | |
#find . -maxdepth 1 -type d -print0 | xargs -0 -i expr "{}" : "\./\(.*\) .[0-9][0-9]" | |
echo "## Chenge owner ##" | |
sudo chown -R nobody:nogroup * | |
echo "## Remove master archive ##" | |
rm -f *.rar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment