Skip to content

Instantly share code, notes, and snippets.

@jhoffmann
Created June 28, 2013 12:09
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 jhoffmann/5884238 to your computer and use it in GitHub Desktop.
Save jhoffmann/5884238 to your computer and use it in GitHub Desktop.
For use with transmission-daemon, enable script-torrent-done-enabled and set this script as script-torrent-done-filename. It will scan your TV folders and try to move the completed torrent into the correct one, by turning both the folder name and torrent name to lower case, stripping out all non alpha characters, and looking for the folder name …
#!/bin/bash
for i in /home/jwh/Downloads/HTPC/TV/*
do
# Look for the TV folder names inside the torrent name
SHOWDIR=`basename "$i" | tr '[A-Z]' '[a-z]' | tr -cd [:alpha:]`
SHOW=`echo ${TR_TORRENT_NAME} | tr '[A-Z]' '[a-z]' | tr -cd [:alpha:]`
if [[ ${SHOW} =~ ${SHOWDIR} ]]
then
# Move, stop and remove the torrent
CMD="mv $TR_TORRENT_DIR/\"$TR_TORRENT_NAME\" \"$i\""
eval $CMD
transmission-remote localhost:9091 --auth=bt:bt -t ${TR_TORRENT_ID} -r
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment