UseSiriWithTaskPaper

This is a very early cut at a script that will move items from Reminders to TaskPaper. It allows the use of Siri on an iPhone 4s to enter new items to the inbox. To use it you will need to change the first two lines to the name and path of your TaskPaper document.

With this, I set up a launchd script to run the script every morning at 4am. Feel free to improve the script. I have a goal to bulletproof it more, but this is at least a working start.

Edited on May 13, 2013 by chris@summersault.com to mark a task that's been copied to TaskPaper as "completed" instead of deleting it altogether; hopefully this is better insurance against failed copies or other issues.

set theDocument to "GTD.taskpaper"
set thePath to "/Users/username/Dropbox/TaskPaper/GTD/GTD.taskpaper"
set theCalendar to "Task Paper"
tell application "TaskPaper"
    open thePath
end tell
tell application "iCal"
    set d to date ("01.01.1000")
    tell calendar theCalendar
        set theTasks to every todo whose not (completion date > d)
        repeat with theTask in theTasks
            set theSummary to summary of theTask
            set dueDate to due date of theTask
            if dueDate ≠ missing value then
                set {month:m, year:y, day:d} to dueDate
                set m to m as integer
                set theYear to y as string
                set theMonth to my zero_pad(m, 2)
                set theDay to my zero_pad(d, 2)
                set theTag to " @due(" & theYear & "-" & theMonth & "-" & theDay & ")"
            else
                set theTag to ""
            end if
            tell application "TaskPaper"
                tell document theDocument
                    tell project named "Inbox"
                        set taskEntry to "- " & theSummary & theTag
                        make new entry with properties {name:taskEntry}
                    end tell
                end tell
                save document theDocument
            end tell
            set completion date of theTask to current date
        end repeat
    end tell
end tell

on zero_pad(value, string_length)
    set string_zeroes to ""
    set digits_to_pad to string_length - (length of (value as string))
    if digits_to_pad > 0 then
        repeat digits_to_pad times
            set string_zeroes to string_zeroes & "0" as string
        end repeat
    end if
    set padded_value to string_zeroes & value as string
    return padded_value
end zero_pad