Defer Omnifocus tasks to random dates


The iOS version of Omnifocus has a nice little feature that moves tasks to a random date in the future (depicted by dice – see screenshot). This comes in very handy when you have tasks that you want to get out of your way and you don't have any specific deadlines for them. Interestingly, the MacOS version of Omnifocus does not have this feature. So, I implemented it with AppleScript and an Alfred workflow to call it with a keyboard shortcut.

The AppleScript

The script is quite straight forward. It uses the same basic structure as my other scripts for Omnifocus [link]. It is also robust enough to work with multiple tasks. You simply have to highlight them and start the script. Each task will then be moved to a different random date. At the end, the scripts cleans everything up (i.e., it calls "Clean up" from the "Organize" menu or when you call ⌘+K in Omnifocus).

The whole script might look a little bit complex, but you can easily adapt it for your needs. You only have to know the magic happens at the end in the function myDeferDate(). It defines a lower and an upper limit for the random date. To mimick the feature from the iOS version I asked the Omnifocus support team about the limits they are using for their iOS version. They defer tasks randomly between 14 and 90 days, which I also used for my script. However, you can easily change them to fit your needs. You can have even various scripts defining different lower and upper limits, for example, to defer certain tasks further into the future, while others only a couple of days.

In any case, based on these values the script randomly chooses a number of days that are added to the current date. For the starting time I use 5:00 AM, since this is my default time. Again you can easily change it to any other time. However, you will have to convert it into seconds (an AppleScript quirk) by multiplying the hours by 3600, (1 hour = 3600 seconds) – for example, 2 PM would be 14*3600 seconds.

Calling the script with a shortcut

I usually call my scripts with shortcuts defined in an Alfred workflow, which allows you to define a key combination that only works for a specific application – in our case – only when Omnifocus is the current active application (i.e., the Omnifocus window is on top of all other open applications). I use the combination ⌃+⌥+⌘ as a prefix for all of my Omnifocus scripts to avoid a conflict with existing shortcuts in Omnifocus. In this case, for moving tasks to random dates in the future, I use ⌃+⌥+⌘+F, where F stands for future. Again changing the shortcut to another one is extremely simple in Alfred. You can download the workflow from here [link].

More ways to defer tasks in Omnifocus

I have written already a number of scripts to move around tasks in Omnifocus. For all of them I have defined shortcuts via Alfred workflows. So, if you like this blog post, you might want to check also the following ones, for example, on how to move tasks to

  • tomorrow morning, noon or evening [link]
  • to upcoming Saturday or Sunday [link]
  • a specific date in the future (e.g. after a deadline or after your holiday) [link]

Work smart, be remarkable, and have a great day!