This information is for TaskPaper 2 which is old and outdated. TaskPaper 3 is the current version of TaskPaper. For TaskPaper 3 support please visit the support forums.

This script creates iCal events in a "TaskPaper" calendar for all events that have a @start and @due tag. Create a calendar with that name prior to running this script. All events in the "TaskPaper" calendar are deleted and then recreated when this script is run.

Important note: This script is currently only working when run in the Script Editor, but not from the scripts dropdown within TaskPaper.

Also, this script is likely to fail ungracefully if you have a @start or @due tag without a date or with a poorly formatted date. Dates are expected to be in YYYY-MM-DD format.

on get_date(taskpaperdate)
    tell (taskpaperdate) as string to text 6 thru 7 & "/" & text 9 thru 10 & "/" & text 1 thru 4
    return date (result)
end get_date

-- First, clear out iCal TaskPaper calendar
tell application "iCal"
    tell calendar "TaskPaper"
        delete events
    end tell
end tell

global start_date_string
global due_date_string

-- Read the entries from TaskPaper and create them in iCal
tell application "TaskPaper"
    tell front document
        repeat with the_entry in entries
            -- For each entry, get the data from TaskPaper
            tell the_entry
                -- Find items that are not done, but have a due date
                -- We will add these to iCal
                if (not (exists tag named "done")) and (exists tag named "due") then
                    -- Get the event properties together
                    set due_date_string to value of tag named "due"

                    if (exists tag named "start") then
                        set start_date_string to value of tag named "start"
                        set start_date_string to due_date_string
                    end if

                    -- Set up the dates
                    set start_date to my get_date(start_date_string)
                    set due_date to my get_date(due_date_string)

                    -- Create the event
                    tell application "iCal"
                        tell calendar "TaskPaper"
                            make new event at end with properties {summary:name of the_entry, start date:start_date, end date:due_date, allday event:true}
                        end tell
                    end tell
                end if
            end tell
        end repeat
    end tell
end tell