Mail AppleScript-ing Project

I have a folder full of old mail in Apple’s Mail application. It’s gigantic. About 70,000 messages. Most of them are duplicates, because it’s the result of finding old folder of mail upon old folder of mail and merging them together into one great hoard. The actual number of real distinct messages is probably a smallish fraction of 70,000.

What’s worse, some of the 70,000 are blank. In an inept attempt at writing a Python script to clean up a similar uber-mail-folder in the past, I somehow took a lot of old mail and destroyed the body of the emails, leaving the headers intact. So my gigantic folder includes many duplicates, but some of the duplicates aren’t real duplicates because they have missing bodies.

I want to somehow eliminate all the duplicate messages, and there are scripts to do that in Apple Mail. The only one that I would have trusted not to accidentally kill a real message and keep the one without a body, chokes and fails on a folder that large. (It also choked and failed on a smaller folder. Maybe something changed in Leopard that breaks that script.)

So I wanted to go through and destroy all the messages which have blank bodies — they’re no use to me and they make it dangerous to get rid of duplicate messages. I tried exporting everything to a mbox-format file, and use some of Python’s nice mailbox-manipulation libraries, but the file was insanely large, and Python on my macbook staggered under its weight. (Besides, my use of Python caused this problem, a while back…)

So eventually I turned to AppleScript. (I first tried using rb-appscript, but it turns out I don’t need any special Rubyness for this, and it’s easier to learn from examples of AppleScript on the web if I don’t have to translate them into Ruby before I use them.)

I wrote a script in Apple’s Script Editor called “Winnower.” It takes messages in a folder called “doing” and sorts them into two folders, “blank” and “done,” depending on whether there’s any content in the body or attachments on the mail. I put a few thousand messages at a time into the “doing” folder and then run the script. (The full weight of the 70,000+ message folder was too much for this script too.)

It looks like this:

tell application “Mail”

set doingbox to mailbox “doing”

set blankbox to mailbox “blank”

set donebox to mailbox “done”

set doingmessages to messages of doingbox

repeat with thisMessage in doingmessages

ignoring white space

if mail attachments of thisMessage is {} and content of thisMessage is equal to “” then

move thisMessage to blankbox

else

move thisMessage to donebox

end if

end ignoring

end repeat

end tell

Obama’s In Control: No More Lobbyist Contributions To Democratic Party

That’s what I’m talkin’ bout.

It’s been less than two days since he crossed the delegate threshold to become the Democratic presidential nominee and Sen. Barack Obama’s mark on the party is already being felt.

On Good Morning America Thursday, ABC News’ Chief Washington Correspondent George Stephanopoulos reported “the Democratic National Committee will no longer accept contributions from federal lobbyists, will no longer take contributions from PACs” in keeping with Obama’s well-publicized policy.

[From Obama’s In Control: No More Lobbyist Contributions To Democratic Party – Politics on The Huffington Post]

I don’t actually think that policy is very well-publicized. I hope it gets more so.

GOP blames Democrats for break-in; police find no political motive

GRAND RAPIDS — Kent County Republicans continue to claim a recent break-in at their Grand Rapids headquarters was politically motivated

And one party leader publicly blamed unnamed Democrats in a mass e-mail sent to supporters.

“We knew the Democrats would do anything to win, but we didn’t expect this!” wrote Kent GOP Chair Dave Dishaw in a note asking for money to help cover “costs” and support candidates. […]

Moore also said he received threatening phone calls two weeks ago when Democratic presidential candidate Sen. Barack Obama held a rally in Grand Rapids, though he did not report them to police.

[From GOP blames Democrats for break-in; police find no political motive – Latest News – The Grand Rapids Press – MLive.com]

I guess Mr. Dishaw thinks that G. Gordon Liddy has defected to the Democrats…

I imagine that there are a lot of people on his mailing lists which will eat that fundraising letter right up.

It was the freshest move I’d ever seen. Like ‘e was floatin’ on air.

Remember the Utah Saints, a Wonder whose One Hit was a spiffy little track “Something Good” consisting of three minutes of a throbbing dance beat with a sample from Kate Bush’s “Cloudbusting” playing over it repeatedly? Apparently they’re, like, still alive and stuff, and they just put out a fun little video.

In it we learn about the mysterious phenomenon that took place on St. David’s Day, 1989, in a little Cardiff nightclub… Lost to history till now, though it has surely affected countless lives.

If I not only remember when this song came out, but remember thinking, back then, “yeah, it’s kinda fun, but it ain’t nothing like as cool as the Kate Bush song it samples…” does that make me… old?

Synchronicity: I was listening to a Kate Bush song (“Joanni”) when I saw somebody link to this song on a message board and followed the link…

White & Donny

When the video for Weird Al’s “White & Nerdy” came out, though it’s all good in a Weird Al kind of way, I found myself mesmerized in particular by the incredibly enthusiastic, goofy guy dancing behind Al in some of the segments…

a guy who turned out to be Donny Osmond. (Al: “I asked him to be in the video because he was the whitest guy I could think of.”) (Me: egads, how old must he be by now? He’s dancing with the energy of a five year old! A five year old on speed!)

Imagine my glee when I discovered that Al had posted to youtube the first take of that dance sequence — with the Donny Dance behind the Gangsta Al, in front of a greenscreen, for the whole song.

You’d think it would get old during the three minute song. You’d think Donny would run out of dance moves. You’d be wrong.