Skip to content

Instantly share code, notes, and snippets.

@brujoand
Created January 20, 2013 15:28
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 brujoand/4579348 to your computer and use it in GitHub Desktop.
Save brujoand/4579348 to your computer and use it in GitHub Desktop.
torrent unpacker
#! /bin/sh
DL_DIR="/c/media/Torrents/Movies"
TRASH_DIR="/c/media/Torrents/Processed"
COMP_DIR="/c/media/sab/complete/cinematic"
findrar() {
path="$1"
file=$(find "$path" -name "*001.rar" -print0 | head -1)
if [ -z "$file" ]; then
file=$(find "$path" -name "*.rar" -print0 | head -1)
fi
echo "$file"
}
find "$DL_DIR" -mindepth 1 -maxdepth 1 -type d -print0 | while read -d $'\0' folder; do
rarpath=$(findrar "$folder")
if [ -z "$rarpath" ]; then
echo "No rarfile found in $folder"
else
moviename="${folder##*/}"
mkdir -p "$COMP_DIR/$moviename"
cd "${rarpath%/*}"
unrar e "${rarpath##*/}" "$COMP_DIR/$moviename/"
mv "$folder" "$TRASH_DIR/"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment