From 83952cc0bf4257e6dcc0fe8932b78aecd04ae7fb Mon Sep 17 00:00:00 2001 From: Morten Date: Wed, 16 Mar 2022 15:24:20 +0100 Subject: [PATCH] correct handling of spaces --- post_download.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/post_download.sh b/post_download.sh index b047a11..6324a46 100644 --- a/post_download.sh +++ b/post_download.sh @@ -2,23 +2,25 @@ # 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')" ]; +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 \; + 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')" ] +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 + 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.."