Skip to content

Instantly share code, notes, and snippets.

@mreidsma
Created July 15, 2013 19:06
Show Gist options
  • Select an option

  • Save mreidsma/6002513 to your computer and use it in GitHub Desktop.

Select an option

Save mreidsma/6002513 to your computer and use it in GitHub Desktop.
Log completed Taskpaper tasks to DayOne and move them from my main todo list into an "Archive file"
set archivedTasks to ""
tell application "TaskPaper"
tell front document
-- don't care which file your log entry came from?
-- comment the next line out
set archivedTasks to "## " & name & return
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 & (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
-- Copy the completed Archive tasks to another file
property archiveFile : "Archive.taskpaper"
property archiveFilePath : "/Users/reidsmam/Dropbox/todo"
tell application "Finder"
if exists (archiveFilePath & "/" & archiveFile) as POSIX file then
tell application "TaskPaper"
set currentFile to name of front document
open archiveFilePath & "/" & archiveFile
move entries of project named "Archive" of document named currentFile to end of entries of document named archiveFile
delete project named "Archive" of document named currentFile
save document named archiveFile
close document named archiveFile
end tell
end if
end tell
-- send the accumulated results to Day One via the command line tool
-- http://dayoneapp.com/faq/#commandlineinterface
do shell script "echo " & (quoted form of archivedTasks) & "|tr -d \"\\t\"|/usr/local/bin/dayone new"
@mreidsma
Copy link
Copy Markdown
Author

Most of this is from Brett Terpstra's Log to DayOne script, cobbled together with the ArchiveCompletedTasks script from rsivaran on the Hog Bay wiki. This is mostly here for reference, and supercedes the script I wrote about at matthewreidsma.com/articles/18

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