Er...somethin' like that.

Thursday, December 06, 2007

Introducing Logsessive

So I’ve been using iChat since it debuted, and had the automatic chat logging turned on for most of that. So every time I send or receive an IM, it gets saved for posterity (for better or for worse).

When iChat first started logging chats, it was only naming them with the name of the other person and an incrementing number- chats with me are “Dan Kuehling #2”, “Dan Kuehling #3”, and on. Later on, I think in one of the versions of iChat for Panther, Apple started adding date and time stamps to the chats- “Dan Kuehling on 2007-12-06 at 22:35”. Now, in Leopard, Apple’s finally decided to do the smart thing and sort all of these chats into dated folders, so all of the chats for a particular day are in a folder named something like “2007-12-06”.

Now that’s great, but the obsessive part of me noticed one problem here: The logs that iChat created before Leopard are still sitting there by the thousands, numbered logs alongside dated logs alongside Leopard’s chat folders.

It’s ugly. It’s messy. It’s stupid. THERE MUST BE ORDER!

I had to fix it.

So I’d been meaning to learn Ruby. It’s got some serious fans at PSIG, most notably the group’s young rock-star Victoria :-)

My task was clear- write a Ruby script to sort these free-floating logs into the folders. So I learned Ruby (or at least what Ruby I know now) the way I always do- Google enough to write a really, really simple little test (even just “Hello World” to start), then expand on it. Add string handling and regexes (which work GREAT in Ruby, by the way), filesystem access with the Dir and File classes, and Date handling. Before I knew it, I’d written a script that walked the ~/Documents/iChats directory, read the date out of the filename, created a directory based on that date (if it doesn’t already exist), and move the log in there. Then, after some work on how to get Mac OS X to give up the real creation date of a file (/usr/bin/mdls -name kMDItemFSCreationDate filename is the key), I got the numbered chat transcripts to take the plunge behind their dated counterparts.

So, without further ado, here’s my brilliant Ruby creation:

Logsessive

The name derives from the how excessive it looks to have all of those logs splayed across the iChats directory and the obsessive nature of wanting everything all neat and tidy. Logsessive!

It includes both the Ruby file and an easy GUI application created with Platypus, if you’re just as obsessive as I am but don’t want to look at the Ruby. (But please do!)

So, on the other side of this, I’ve come out of this really digging Ruby. After I finished Logsessive, I was looking around with other things to do with it.

No comments: