TaskPaper To Reminders AppleScript


This afternoon while watching the cricket I was doing some project maintenance in TaskPaper and really wanted to be able to easily add a task to Reminders so that my phone could remind me.

Some wrangling with AppleScript (never really fun if only because Applescript gets so huffy about data types) I came up with a solution. I don’t know how well it will work in the US, with your different date order, but I think it should be fine if you type your date order in TaskPaper then AppleScript should do the text to date conversion OK.

The script has no real error checking and uses a highly specific format for your task — “Remind me @due 29/1/2013 4:00PM” will create a reminder “Remind me” for 4 PM on the 29th of January 2013 and the order of each of the pieces must be in the right spot and the format of the date and time must be as in the example above excepting that if you are in the US you should swap the day and month. You can drop the time and then the time of the reminder will be set to 9AM.

	on explode(delimiter, input)
		local delimiter, input, ASTID
		set ASTID to AppleScript's text item delimiters
			set AppleScript's text item delimiters to delimiter
			set input to text items of input
			set AppleScript's text item delimiters to ASTID
			return input --> list on error eMsg number eNum
			set AppleScript's text item delimiters to ASTID
			error "Can't explode: " & eMsg number eNum
		end try
	end explode

	# example of the format of TP task script requires
	# set theReminder to "Remind me @due 29/1/2013 4:00PM"

	tell application "TaskPaper"
		set theReminder to name of selected entry of front document
	end tell

	set splitReminder to explode("@", theReminder)
	set remText to item 1 of splitReminder
	set remDue to item 2 of splitReminder
	set splitDue to explode(" ", remDue)
	set dueDate to item 2 of splitDue
	set dueTime to ""
	if length of splitDue > 2 then set dueTime to item 3 of splitDue
	if dueTime is equal to "" then set dueTime to "9:00AM"	set remDate to date (dueDate & " " & dueTime)	tell application "Reminders"
		tell list "Reminders"
			make new reminder with properties {name:remText, due date:remDate}
		end tell
	end tell

Put the script in your Scripts folder and then in TaskPaper put the cursor on the task you want turned into a Reminder. If you find this useful please tell me.

Update: This script was far too fussy so I rewrote it. You can grab the new one and read all about it here.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s