#!/bin/sh # A simple script to extract a rar file inside a directory downloaded by Transmission. # It uses environment variables passed by the transmission client to find and extract any rar files from a downloaded torrent into the folder they were found in. # It will also try to copy *.srt/subtitle files if found. # # v1.1 - Added quotation marks to $TR_TORRENT_NAME to help with spaces dest_folder="/media/SpockVault/Downloads/Processing/" # Script starts echo "Post-processing $TR_TORRENT_NAME after finished download" if [ -n "$(find $TR_TORRENT_DIR/"$TR_TORRENT_NAME" -name '*.rar')" ]; then echo "Processing *.rar $TR_TORRENT_NAME to processing-dir" touch $dest_folder/post_download_in_progress.md find $TR_TORRENT_DIR/"$TR_TORRENT_NAME" -name "*.rar" -execdir unrar e -o- "{}" $dest_folder \; rm $dest_folder/post_download_in_progress.md elif [ -n "$(find $TR_TORRENT_DIR/"$TR_TORRENT_NAME" -iname '*.mkv' -or -iname '*.mp4' -or -iname '*.avi')" ] then touch $dest_folder/post_download_in_progress.md echo "Processing video file from $TR_TORRENT_NAME to sickchill-dir" find $TR_TORRENT_DIR/"$TR_TORRENT_NAME" -iname '*.mkv' -or -iname '*.mp4' -or -iname '*.avi' -or -iname '*.srt' | grep -iv sample | xargs cp -t $dest_folder rm $dest_folder/post_download_in_progress.md else echo "No suitable files found, not doing anything.." fi