Skip to content

Instantly share code, notes, and snippets.

@bkanuka
Last active January 28, 2020 20:11
Show Gist options
  • Save bkanuka/30fe219a998897ac609432aeb2f0224b to your computer and use it in GitHub Desktop.
Save bkanuka/30fe219a998897ac609432aeb2f0224b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
## Uses transmission-remote to remove public torrents only
## This keeps private torrents up to keep seeding
TORRENTS=$(transmission-remote -t all -i | \
grep -e 'Id:' -e 'Name:' -e 'Percent Done:' -e 'Public torrent:' | \
cut -d':' -f2 | sed -e 's/^[[:space:]]*//' | \
paste -sd '\t\t\t\n')
while IFS="\n" read -r torrent; do
while IFS=$'\t' read -r id name percent public; do
# We now have all the varibles
if [[ $percent = "100%" ]]; then
if [[ $public = "Yes" ]]; then
echo "Torrent $name is complete and public"
echo "Removing $name ..."
transmission-remote -t "$id" -r
fi
fi
done <<< "$torrent"
done <<< "$TORRENTS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment