This Week's Sponsor:

FastMinder

A Simple, Lightweight, and Clutter-Free Intermittent Fasting Tracking Experience


Send Selected OmniFocus Task to Plain Text File

I save a lot of stuff into OmniFocus: bits of text, URLs, emails. I used to save favorite tweets into it, too. The app’s Quick Entry panel is so easy to invoke and so well-integrated with core parts of OS X  that, most of the time, I find myself clipping information that shouldn’t be into OmniFocus at all. However, I also find the process of manually going through that information beneficial to my workflow: it allows me to mentally and practically separate actionable items (tasks) from things to read and things to write (Instapaper material and my future articles, essentially).

I have created a simple AppleScript to send the selected OmniFocus task to a text file. The script is meant for how I use OmniFocus; hopefully you’ll find it useful as well. Feel free to modify it.

Typically, when I decide to go through my OmniFocus inbox, I find a lot of tasks that are actually ideas of things I want to do or write. Ideas don’t go into OmniFocus. Until those ideas become actionable items, I send them to a text file so I can elaborate on them and see if they can evolve. Like I said, most of the time those ideas are for new articles.

I store all my notes in a single Apps/ directory on my Dropbox. Based off the same AppleScript, I have created a Keyboard Maestro macro to create a new text file for each processed task; this is for ideas I know will turn out to be single, standalone articles. For ideas I’m not so sure about, I prefer to append them as text to an Ideas.txt file I keep in Dropbox as an “everything bucket” for inspiration.

AppleScript

This is the underlying AppleScript:

tell application "OmniFocus"

	tell front window

		set my_sel to selected trees of content

		set my_selection to value of item 1 of my_sel

		set task_name to get name of my_selection

		set a_note to get note of my_selection

	end tell

end tell

Simple enough, it grabs the name and note of a selected task in OmniFocus (I am assuming you’ll run this script when OmniFocus is the frontmost window, as you’re processing your Inbox or another perspective). The implementation varies slightly between Keyboard Maestro (which creates single files) and Ideas.txt.

Keyboard Maestro

The macro, pictured below, uses Keyboard Maestro Engine’s support for variables in AppleScript to assign a task’s name and note (if any) to two separate variables. It then brings up a user prompt to confirm you want to name a text file as the task’s name, and use the task’s note for the file’s contents.

The %Variable%TaskName% defines the path for “Write Text to File” you see at the end of the macro, so make sure the file path works for you.

tell application "OmniFocus"

	tell front window

		set my_trees to selected trees of content

		set my_selection to value of item 1 of my_trees

		set task_name to get name of my_selection

		set task_note to get note of my_selection

		tell application "Keyboard Maestro Engine"

			make variable with properties {name:"TaskNote", value:task_note}

			make variable with properties {name:"TaskName", value:task_name}

		end tell

	end tell

end tell

The macro is designed to understand if TaskNote is empty, and, in that case, it won’t add any text to the newly created TaskName file. You can download the macro here.

Append to File

When I want to append a selected task to an existing Ideas.txt file, I use an AppleScript. You can trigger AppleScripts in a variety of ways these days (Alfred, LaunchBar, Keyboard Maestro), including putting them in the OmniFocus toolbar (to do so, place them in ~/Library/Scripts/Applications/OmniFocus/).

-- PATH OF TEXT FILE YOU'LL APPEND TEXT TO

property text_file : "/Users/viticci/Dropbox/Apps/Ideas.txt"


-- GET TASK NAME AND NOTE FROM OMNIFOCUS

tell application "OmniFocus"

	tell front window

		set my_sel to selected tree of content

		set my_selection to value of item 1 of my_sel

		set task_name to get name of my_selection

		set a_note to get note of my_selection

		-- CHECK IF NOTE IS EMPTY

		if a_note is not "" then

			set task_note to {" - " & a_note}

			
			-- APPEND DATE, TASK NAME + NOTE TO IDEAS.TXT FILE
	
			do shell script "echo \"


_\"`date +'%Y-%m-%d'`\"_\" >> " & text_file

			do shell script "echo " & task_name & task_note & ">> " & text_file

			
		else if a_note is "" then

			
			-- APPEND DATE AND TASK NAME TO IDEAS.TXT FILE
	
			do shell script "echo \"


_\"`date +'%Y-%m-%d'`\"_\" >> " & text_file

			do shell script "echo " & task_name & ">> " & text_file

		
		end if

	end tell

end tell

This variation of the AppleScript gets the task’s name and note, and appends them after a date string to an Ideas.txt file.

You can edit the property text_file at the top of the script to set it to your path; note that, if a task has an empty note, only the name will be appended.

Wrap-Up

Personally, I use this at the end of each day to go through my OmniFocus inbox and create text files for ideas I’ve saved. The script works particularly well with nvALT if you’ve set the app to pick up .txt files off a local folder. If you happen to build a modification of the script for a different workflow, feel free to ping me.

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.