News Flush

Here’s an that flushes read e-mails and unflagged e-mail from my inbox. It took me quite a while to figure out that AppleScript would also obtain IDs for deleted messages (i.e., non-expunged ones) and turn what was supposed to be a simple operation into a massive churning of my disk drive as the blubbering idiocy that is tried to delete things it had already deleted and fell all over itself.

So I just added the rather nonsensical and deleted status = false, and lo, it was massively faster.

Since this doesn’t care about specific messages, it is designed to be activated from the (or via ):

tell application "Mail"
  set theMessages to (every message in mailbox "INBOX" of account "News"
whose read status = true and flagged status = false and deleted status = false)
    try
      tell application "Mail"
        delete theMessages
      end tell
    end try
end tell