Advertisement

AppleScripting OmniFocus > Swap Task Names and Notes

AppleScripting OmniFocus  Swap Task Names and Notes

I use OmniFocus on a daily basis to keep track of important tasks. On a few occasions, I've entered tasks and assigned notes to them, only to decide later that I'd rather use the note as the task name, and the task name as the note. Rather than manually cycling through my tasks and swapping the notes, I wrote an AppleScript to do it. Now, anytime I want to perform this task, I can simply run the script. Here's how I did it...

Creating the Script

1. Launch AppleScript Editor (in /Applications/Utilities).

2. If your system-wide script menu isn't enabled already, go into AppleScript Editor's preferences window and turn it on.

AppleScripting OmniFocus  Swap Task Names and Notes

The script menu is enabled in AppleScript Editor's preferences window.

3. Create a new script document and enter the following code:

Note: You can download the complete script here.

4. Bring OmniFocus to the front, and from the system-wide script menu, choose Open Scripts Folder > Open OmniFocus Scripts Folder. This creates the following folder, if it doesn't already exist - ~/Library/Scripts/Applications/OmniFocus.

AppleScripting OmniFocus  Swap Task Names and Notes

The script menu automatically creates application script folders if they don't exist

5. Go back to AppleScript Editor and save the script as OmniFocus > Swap Selected Task Names and Notes into the ~/Library/Scripts/Applications/OmniFocus folder you opened in the last step.

AppleScripting OmniFocus  Swap Task Names and Notes

Scripts added to the OmniFocus scripts folder appear in the script menu only when OmniFocus is in the front

Running the Script

To run the script, just select one or more tasks in OmniFocus. Then, select OmniFocus > Swap Selected Task Names and Notes from the script menu. The script retrieves the selected tasks, loops through them, and swaps their names and notes. You can run the script a second time, if you decide you'd rather swap them back.

AppleScripting OmniFocus  Swap Task Names and Notes

Some OmniFocus tasks with notes

AppleScripting OmniFocus  Swap Task Names and Notes

Trigger the script from the script menu to process selected notes

AppleScripting OmniFocus  Swap Task Names and Notes

The script warns you that swapping task names and notes will remove any note formatting

AppleScripting OmniFocus  Swap Task Names and Notes

The script notifies you when processing is complete. It skips any notes that contain attachments, and lets you know if this occurred.

AppleScripting OmniFocus  Swap Task Names and Notes

The processed OmniFocus tasks, with swapped names and notes

Whether you need to swap task names and notes or not, this should give you some insight into the scripting capabilities of OmniFocus. I'll be posting other OmniFocus scripts in the future. So, if you're an OmniFocus user, stay tuned. If you're not an OmniFocus user, then you should be. Go to the Omni Group's website and download the trial today! Happy scripting!