Skip to content

Instantly share code, notes, and snippets.

@alexnorton
Last active September 23, 2023 05:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexnorton/1a6bfcf3528bd18f8dfb to your computer and use it in GitHub Desktop.
Save alexnorton/1a6bfcf3528bd18f8dfb to your computer and use it in GitHub Desktop.
Find Transmission "ophan" torrents

This script will list files and folders in the specified directories that don't belong to torrents currently being managed by Transmission.

This is useful for finding torrents that have been removed from Transmission but haven't had their files deleted from the downloads folder.

#!/bin/bash

DIRECTORIES="/mnt/Disk1/Downloads /mnt/Disk2/Downloads"

grep -Fxv -f \
  <( \
    transmission-remote -l | awk 'NR!=1 {sub(/*/, "", $1); print $1}' | sed \$d | while read id; do
      transmission-remote -t $id -i | sed -n -E -e "s/(Name|Location): (.+)/\2/p" | sed -E "N;s/  (.+)\n  (.+)/\2\/\1/"
    done
  ) \
  <(find $DIRECTORIES -mindepth 1 -maxdepth 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment