Insert Date
So yesterday I listened to most of the Mac Power User Podcast with Merlin Mann. It’s long. I walked for over 5½ miles and I didn’t get through the whole thing. Hearing about different ways to do Mac things is useful and distracting on a long walk.
Listening to the podcast, I decided to stop using VoodooPad for my to do list and quick note taking. It works great as a sort of notebook to keep track of projects and as a How-to manual for my life. However, without an editable mode in the iPhone app, it’s not really well-suited for use as a to do list.
I’d already started using Simplenote as a to do list and Seth has been insistent on the usefulness of syncing Simplenote to Notational Velocity on the desktop. But Seth is just Seth. He didn’t sell me. But Merlin was in full carnival barker mode on the Simplenote-Notational Velocity combo. Hell, he almost – almost – sold me on TextMate too.
Anyways, I quickly set all of that up. I still needed to be able to automatically insert dates into the note titles just like Merlin. He uses TextExpander, but that sounded like one too many new apps to adopt in one week. I figured I could cook-up a little AppleScript and assign a keyboard shortcut in FastScripts. FastScripts is already how I manage to live with Mail.app and it feeds soothes my OCD in iTunes too.
A little Google fu turned up a hint to get me pretty close to what I wanted. So I started with that, but I couldn’t seem to get the keyboard shortcut to work. A very quick and helpful email exchange with Red Sweater Software fixed what was wrong with my script. And now I can insert dates into text fields with a flick of a few fingers.
It’s always amazing to me how great the customer service is from so many different Mac developers. I think we should be great users too. So more or less because of the great software and insanely fast email responses (and hey also because I was approaching the limit for the free version) I purchased FastScripts. I guess I’ll need to throw Merlin a bone and buy his book when it comes out too. Nice things cost money and nice people need to eat.
Anyways, here’s the AppleScript I used. It will insert a YYYYMMDD style date.
delay 0.5
set {year:y, month:m, day:d, time string:t} to (current date)
set date_format to (y * 10000 + m * 100 + d) as string
set reformated_date to (text items 1 thru 4 of date_format as string) & (text items 5 thru 6 of date_format as string) & (text items 7 thru 8 of date_format as string)
tell application “System Events” to keystroke (reformated_date)