Skip to content

Instantly share code, notes, and snippets.

@chrodriguez
Last active January 6, 2024 22:48
Show Gist options
  • Save chrodriguez/eeb55e52917b8c4effeb to your computer and use it in GitHub Desktop.
Save chrodriguez/eeb55e52917b8c4effeb to your computer and use it in GitHub Desktop.
Transmission delete finished torrents
#!/bin/sh
TORRENTLIST=`transmission-remote --auth=user:pass --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=' ' --fields=1`
for TORRENTID in $TORRENTLIST
do
echo "* * * * * Operations on torrent ID $TORRENTID starting. * * * * *"
DL_COMPLETED=`transmission-remote --auth=user:pass --torrent $TORRENTID --info | grep "Percent Done: 100%"`
STATE_STOPPED=`transmission-remote --auth=user:pass --torrent $TORRENTID --info | grep "State: Stopped\|Finished\|Idle"`
if [ "$DL_COMPLETED" != "" ] && [ "$STATE_STOPPED" != "" ]; then
echo "Torrent #$TORRENTID is completed."
echo "Removing torrent from list."
transmission-remote --auth=user:pass --torrent $TORRENTID --remove
else
echo "Torrent #$TORRENTID is not completed. Ignoring."
fi
echo "* * * * * Operations on torrent ID $TORRENTID completed. * * * * *"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment