

~/.session (rtorrent) or ~/.config/deluge/state (Deluge) or ~/.config/transmission/torrents/ (Transmission) I've edited the script for clarity by removing unnecessary comments and capitalization within in addition to changing the (rather informal) paths and adding the line to address the lost+found directory: #!/bin/bashĮcho Usage: $0 $HOME/path-to-the-session-directory/ /path-to-the-torrent-data-directory/ This Bash script was created in the 2020s by a Reddit user (who has since deleted their related posts). I suspect it might break with unusual filenames too. I'm far from an expert at bash scripting and this is quite a slow script with a large number of torrents as searching for the substring with this method seems slow, feel free to suggest alternatives. It will also delete any files not listed in Transmission, such as the "Incomplete" directory, if you keep it in your downloads folder. I recommend running the script first to see what will be deleted before doing it. Note that the line to actually delete the files is commented out.

# does it not start with an underscore (my special char for files in directory not related to transmission # does it NOT exist in the list of all torrent files Transmission-remote 127.0.0.1 -t all -files > _all_torrents.tmp # get a list of all torrents transmission-remote 2.52 Using derobert's answer I wrote a bash script to remove all files that aren't listed by transmission-remote #!/bin/bash
