AppleScript Experiments: "Later" in OmniFocus and Save As PDF

Update (January 1, 2013): Later.scpt has been updated to allow for absolute date and day of the week date syntaxes. For the most recent version of these and future projects, please take a trip to the Projects page.

On Christmas I received a number of books (which, if the past is any indication, will still be largely unread by next Christmas) on the topic that has really been grabbing my attention these days: programming. From the pile of dead trees I decided to start with Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X. Since Christmas day, I have been reading voraciously (though, still not at a swift enough pace to make a significant dent in the 1000-page behemoth), and built two practice scripts that I am pretty excited about. I decided to share these here in the hopes that you, too, might have a use for them1.

Deferring OmniFocus Tasks With OmniFocus-like Syntax: "Later"

Download the script: Later.scpt

I have been a happy user of Dan Byler's OmniFocus AppleScripts (in particular, the "Defer" script that postpones a task's start date by a user-determined number of days) for awhile, but the inability to define the desired start date in OmniFocus's excellent date syntax has always frustrated me. I decided to have a go at replicating the date parser in AppleScript so that I could push a task to a very specific amount of time from today.

The script I built does what I need it to, though your mileage may vary. The script will initially ask if you want to automatically flag tasks while deferring them (which is the basis of my OmniFocus workflow), and will then present a dialog box for you to enter the amount of time to defer the task for. The syntax is the same as OmniFocus's: you can use "weeks", "w", "days", "d", and 24- or 12-hour time specifiers (with or without the AM/a/PM/p). So, for example, writing "2w 4d 12:40pm" would defer the start date of that task for two weeks, and four days, and would set the start time to 12:40pm. You can exclude any of the three pieces and it will still work (as long as you specify at least one item).

A few things: OmniFocus is frustratingly slow at setting the start date of tasks via AppleScript. Every script I looked at, including my own, took about half a second to set the start date for each task no matter what I did. Also, if you have a Retina Mac, be warned: AppleScript does not seem to have access to retina-fied dialog windows, so those look absolutely awful.

Additionally, I have left a lot out that I might add in sometime in the future: the ability to defer due dates instead of (or in addition to) start dates (which I disagree with on a technical level, by the way), the ability to set the date directly instead of relatively, and the use of Growl for notifications.

Saving Word and PowerPoint Files as .pdf

Download the script: Save MS Office as PDF.scpt

The second script was a little simpler and one I wish I didn't need. However, as a student, I receive an enormous amount of .doc/.docx and .ppt/.pptx files. Setting aside the fact that I find Word and PowerPoint to be inferior to Pages and Keynote, respectively (or, in the case of Word, inferior even to a plain text file), viewing these files on iOS devices can result in weird layout problems, and their long-term portability is anything but assured.

The script initially asks whether you use Path Finder or Finder for your file browsing. It then takes the file selection from your preferred application, ignores any non-Word and non-PowerPoint files selected, and starts saving them to the same directory as the original file. It also asks if you want to convert both the Word and PowerPoint files (or only one or the other) if it detects that you have selected both types.

For this script, I will probably work on improving the Path Finder/ Finder selection process, and I may add the option to have the script automatically delete the original Word and PowerPoint files. Other than that, I am fairly happy with this script, though it is still limited by the speed of Word and PowerPoint. It's still miles ahead (both in terms of speed and reliability) of the GUI scripting-based process I had done in Keyboard Maestro.

If you have any comments about the scripts or would like to see something added, feel free to shout at me on Twitter as @pxldots.


1. I find it an incredible part of the world we live in that, with just one good book and the internet at your disposal, even a non-programmer can learn so much, so quickly.  ↩