Created
January 20, 2013 15:28
-
-
Save brujoand/4579348 to your computer and use it in GitHub Desktop.
torrent unpacker
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/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