Skip to content

Instantly share code, notes, and snippets.

@mreidsma
Created April 17, 2012 03:38
Show Gist options
  • Save mreidsma/2403233 to your computer and use it in GitHub Desktop.
Save mreidsma/2403233 to your computer and use it in GitHub Desktop.
Applescript to archive completed Taskpaper tasks to Google Calendar with ifttt.com
-- Archive completed Taskpaper tasks to Google Calendar with ifttt.com
-- First, set up the following recipe at ifttt.com to add completed tasks to your calendar:
-- http://ifttt.com/recipes/30256
--
-- Then use this Applescript to archive tasks. Mail.app needs to have the default account match your ifttt.com email
-- Let me know if you have any questions: [email protected] or @mreidsma
set archivedTasks to ""
tell application "TaskPaper"
tell front document
-- This next section from Stefano F. Rausch's Archive Entries Applescript
-- http://www.hogbaysoftware.com/wiki/ArchiveAllOrSelectedDoneEntries
-- Make sure there is an archive project
if not (exists project "Archive") then
make project with properties {name:"Archive"} at end
end if
set archive to project named "Archive"
-- This whole function is from Brett Terpstra's excellent Taskpaper to DayOne script
-- http://brettterpstra.com/log-taskpaper-archives-to-day-one/
repeat with _task in search with query "project != Archive and @done"
if entry type of _task is not project type then
-- remove common tags that won't matter after archiving
repeat with _tag in {"na", "next", "priority", "waiting"}
if exists (tag named _tag of _task) then delete tag named _tag of _task
end repeat
-- if there's no project tag on the task,
-- add the task's current project as a tag
if not (exists (tag named "project" of _task)) then
tell _task to make tag with properties {name:"project", value:(name of containing project of _task as rich text)}
end if
-- append the full text of the entry, including tags, to our log
set archivedTasks to archivedTasks & "Tasks: " & (text line of _task)
-- archive it
move entry id (id of _task) to beginning of entries of project "Archive"
end if
end repeat
end tell
end tell
-- Check to see if there were any completed tasks
if archivedTasks is not "" then
-- Send mail to ifttt to archive to calendar
tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:"Completed #task", content:archivedTasks, visible:false}
tell theNewMessage
make new to recipient at end of to recipients with properties {address:"[email protected]"}
send
end tell
end tell
end if
@mreidsma
Copy link
Author

I now send these completed tasks to Day One, a great journaling app that lets you export as plain text. I pretty much use the stock script from Brett Terpstra (which I originally modified here) http://brettterpstra.com/log-taskpaper-archives-to-day-one/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment