I've been using Transmission to download various torrents, but every now and then the client does not remove the file but removes the torrent file.

This makes it that my download folder is full of already removed torrents, but the files are still there.

What is the best way to find which files are currently not linked to any loaded torrent and remove them?

  • "Remove" and "remove and delete data" are two separate operations in Transmission, for the very good reason that you don't always want to get rid of the files you downloaded when you stop participating in the swarm. If you want to delete the files associated with torrents you've already removed, use the rm command.
    – Tom Hunt
    Commented Dec 2, 2015 at 22:12
  • I've used the remove and delete data, it just doesn't always remove the files. There is no space being freed. - removing the files manually could help.. But with over 50k files and 1k torrents currently active I woudn't even know which ones can be deleted. (Thats what I want to find out)
    – Isa
    Commented Dec 2, 2015 at 22:20
  • find -mtime +7 or find -atime +7 perhaps? Commented Dec 2, 2015 at 22:51
  • 1
    @roaima Seems to print thousands of false positives (~10,000 active torrents).
    – user598527
    Commented May 29, 2022 at 12:01

2 Answers 2


Using derobert's answer I wrote a bash script to remove all files that aren't listed by transmission-remote


# get a list of all torrents transmission-remote 2.52
transmission-remote -t all --files > _all_torrents.tmp

# all items in this directory
for i in * 
        # is it a file or a directory
        if test -f "$i" -o -d "$i"
                # does it NOT exist in the list of all torrent files
                #if [[ $all_files != *"$i"* ]]
                if ! grep -Fq "$i" _all_torrents.tmp
                        # does it not start with an underscore (my special char for files in directory not related to transmission
                        if [[ "$i" != _* ]]
                                # delete them
                                echo rm -rf \"$i\"
                                # rm -rf "$i"

# clear tmp file
rm _all_torrents.tmp

Note that the line to actually delete the files is commented out. I recommend running the script first to see what will be deleted before doing it. It will also delete any files not listed in Transmission, such as the "Incomplete" directory, if you keep it in your downloads folder.

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. I suspect it might break with unusual filenames too.


You can ask transmission-remote for a list of the files it knows about. There are two options for asking for files, --files and --info-files/-if; which you need probably depends on the version you're running:

$ transmission-remote «host» -N ~/.transmission-netrc -t all --files    # or -if
musopen-lossless-dvd (4 files):
  #  Done Priority Get      Size  Name
  0: 100% Normal   Yes   8.07 GB  musopen-lossless-dvd/Musopen-Lossless-DVD.zip

Unfortunately, it's intended for display, not parsing, and there doesn't seem to be an option to make scripting-friendly output. If you're a programmer, you could grab the source and fix that or alternatively hack together your own implementation in Perl/Python/Ruby/JavaScript/etc. to get the file names. Transmission uses a documented, fairly simple JSON-over-HTTP protocol.

You could also try --move to ask Transmission to move everything it knows about to a new directory.

  • 1
    Thank you, I'll just move all the files and remove the ones that are left behind (Not 'owned' by transmission anymore).
    – Isa
    Commented Dec 2, 2015 at 22:44
  • @Bart I'd suggest keeping a copy of them for a bit (at least across a Transmission restart) just in case --move is as buggy as --remove-and-delete apparently is for you...
    – derobert
    Commented Dec 2, 2015 at 22:45
  • Is it possible to print only the files Transmission doesn't know about?
    – user598527
    Commented Feb 12, 2021 at 9:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .