Skip to content

Instantly share code, notes, and snippets.

@frah
Created Oct 15, 2012
Embed
What would you like to do?
#!/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