ThreadKiller 7.0

Updated January 26, 2006

So you're on this mailing list, which you like, but it gets dozens, or even hundreds, of messages per day, and most of it is on topics that you're not really that interested in, or don't have time to read. So you keep hunting down the topics you like, and then deleting the rest. And sometimes you forget, and delete threads that you are interested in, or you can't find the topic you were reading yesterday because you've forgotten the subject. Plus, there's this one topic that you really don't want to read, but people keep talking about it and talking about it, and you have to delete it over and over again. There's got to be a better way.

There is. Use ThreadKiller to mark and delete one message in the thread you don't want to read, and from then on, ThreadKiller will automatically clear out all current and future messages in that same subject thread. Conversely, you can flag a message, and ThreadKiller will flag all other messages that arrive in that thread.


Apple's "Mail" program included with OSX (this script's been tested with Mail 1.3, but will probably work with earlier versions as well).

A POP or IMAP mail account. (Not tested with Hotmail-type accounts.)

How To Use It

Optionally, create a folder or folders in Mail for your mailing list messages, and create a rule (or use the Mailing List Manager) to put them all there.

Put ThreadKiller in [your home folder]:Library:Scripts:Mail Scripts. Optionally, rename it to ThreadKiller___ctl-k so you can use Control-K (hold down the Control key and tap the K key) to rapidly kill lots of messages. Otherwise, you'll have to select ThreadKiller from the script menu.

When you first open the folder with the mailing list messages, invoke ThreadKiller. It will sweep out all the messages you've previously marked as uninteresting. Then you can start reading what remains. Whenever you see a message that you'd like to kill, highlight it and invoke ThreadKiller. That message will get filed in ThreadKiller's 'undesirable subject' list, and all similar messages (even those with multiple "Re: " in front) will be deleted from the folder.

If there's a thread you particularly don't want to miss, tell Mail to Flag it, then 'kill' it with ThreadKiller. All subsequent messages that arrive in that thread will also be flagged, not deleted, when you run ThreadKiller on the folder as a whole.

How It Works

ThreadKiller keeps track of things in a folder named "ThreadKiller" inside "Application Support" in your home "Library" folder.

For every mail folder that you use ThreadKiller on, it creates a Finder folder with the same name. When you 'kill' a message, it makes an empty file in the Finder folder. That file's name is the same as the subject of the message you're killing (or flagging), minus any "Re: " and "[maillist name]" constructions from the front. If it's a message you're killing, the file will be given a red color label. If you're keeping it, the file will be green.

When you run ThreadKiller and you haven't selected a specific message, then it assumes you want all eligible threads in the folder cleaned out. It goes through each message in the Mail folder, deleting or flagging matching messages as appropriate. Every time it does so, it changes the date of the Finder file so it can keep track of how recently a thread popped up and needed to be killed. When it's done, any message that hasn't been used in a week is thrown out, on the grounds that people have apparently stopped talking about that subject. If you want to change that interval, just edit the "DaysToExpire" property right near the top of the script.

Potential Problems

I've managed to speed it up a lot from earlier versions, but it's still not blazingly fast. However, most of the remaining speedups would make it less stable, so I'm just leaving it alone for now.

Making lots of little files on the hard drive uses up space. Even though they're "empty," they might take up 8Kbytes each or so. So if I were being "good," I'd use a single file and keep the subjects in it. But using individual files on the drive makes it so easy to keep track of the date (through the modification date) and the flagged/killed status (through color labels), and c'mon, hard drive space isn't that precious anymore. I may change it one of these days, but probably not; it works just fine as it is.

The Script

You can download it as a Compiled Script.

Historical Notes

The last version I posted was 5.1 for Entourage, and it was released March of 2003. It's taken me quite a while to get a good working version for Mail, due in part to some very crappy AppleScript support in earlier versions of Mail itself. Version 6 "worked" like my 5.x scripts did, using folders inside the mail program to track messages. Mail still seems nearly incapable of deleting messages correctly, and it would only move them most of the time, causing erratic failures. Version 7 has been extensively rewritten to use the file system to store message records, and it's proven immensely more reliable.

Kudos & Cover

This script is an original work by Dave Howell, and is copyright 2002-2006. Others are welcome to download it, use it, make modifications, and adapt it, as long as appropriate credit/notice is retained. [For example: "Parts of this script are copyright 2002 by Dave Howell." or whatever.] Please do not distribute this script without written permission from me. Distributing a link or pointer to this page is fine.

If you find this script useful or handy, all I ask is that you take the time to drop me an email and say so. The more feedback I get (even negative feedback, to a certain degree) the more motivation I have to prepare some of my other scripts for posting, after all. Thanks.