Skip to content

Instantly share code, notes, and snippets.

@frah
Created October 15, 2012 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frah/3892253 to your computer and use it in GitHub Desktop.
Save frah/3892253 to your computer and use it in GitHub Desktop.
#!/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