Posts Tagged ‘seed ratio’

Transmission, move completed downloads/torrents

November 23rd, 2012 3 comments

I wanted to be able to move torrents that were completed and had a stopped state. (Which would occur when you stop them from the interface or when the seed ratio has been met) I was inspired by this script. I fixed it a bit and I am now using it to move completed torrents from my SSD to my larger platter based disks so that I don’t have to keep them spinning while downloading/uploading. I first used awk to get the columns but then switched to cut. Use whatever you like or just copy-paste and modify the MOVEDIR and BASE_COMMAND params. Make sure that the user transmission is running on has write permissions on the folder the data is moved to.

BASE_COMMAND="transmission-remote -n yourusername:yourpassword"
TORRENT_ID_LIST=$($BASE_COMMAND -l | sed -e '1d;$d;s/^ *//' | cut -d ' ' -f 1)
        NAME=$($BASE_COMMAND -t $TORRENT_ID -i | grep -i "Name:" | sed 's/^ *//' | cut -d ' ' -f 2-)
        PERCENT_COMPLETE=$($BASE_COMMAND -t $TORRENT_ID -i | grep -i "Percent Done:" | sed 's/^ *//' | cut -d ' ' -f 3)
        STATE=$($BASE_COMMAND -t $TORRENT_ID -i | grep -i "State:" | sed 's/^ *//' | cut -d ' ' -f 2)
        RATIO=$($BASE_COMMAND -t $TORRENT_ID -i | grep -i "Ratio:" | sed 's/^ *//' | cut -d ' ' -f 2)
        if [ "$PERCENT_COMPLETE" = "100%" ] && ( [ "$STATE" = "Stopped" ] || [ "$STATE" = "Finished" ] ); then
                echo "Torrent $NAME is completed"
                $BASE_COMMAND -t $TORRENT_ID --move $MOVEDIR
                $BASE_COMMAND -t $TORRENT_ID -r
                echo "\tTorrent data moved and removed from transmission"