ParseClipboardInFantastical

Use Fantastical to add Taskpaper tasks as Reminders

2014-02-07 by Derick Fay

updated 2014-04-06 with multi-line version

requires Fantastical

These are a pair of Applescripts which will parse the contents of the clipboard in Fantastical and if the clipboard contains a @due(YYYY-MM-DD) tag, it will convert it to the text

due YYYY-MM-DD

which Fantastical will parse as a Reminder.

I have these installed as Automator Applescript Services so they are accessible by right-clicking in any app (including TaskPaper, of course).

Change Fantastical to Fantastical 2 and it works fine with F2

Parse a Line in Fantastical

Processes a single line and allows you to edit it in Fantastical before adding.

tell application "Fantastical"
set theText to get the clipboard
set theTextDate to ""
if theText contains "@due(" then
    set s to (offset of "@due(" in theText)
    set theTextDate to text (s + 5) thru (s + 14) of theText
    set theStart to text 1 thru (s - 1) of theText
    set theEnd to ""
    try
        set theEnd to text (s + 16) thru -1 of theText
    end try
    set theText to theStart & theEnd
end if
if theTextDate is not "" then
    set theText to theText & " due " & theTextDate
end if
parse sentence (theText)
end tell

Parse Multiple Lines in Fantastical

Processes multiple lines and adds them all to Fantastical at once.

set t to the clipboard
set theLines to paragraphs of t
tell application "Fantastical"
repeat with theText in theLines
    set theTextDate to ""
    if theText contains "@due(" then
        set s to (offset of "@due(" in theText)
        set theTextDate to text (s + 5) thru (s + 14) of theText
        set theStart to text 1 thru (s - 1) of theText
        set theEnd to ""
        try
            set theEnd to text (s + 16) thru -1 of theText
        end try
        set theText to theStart & theEnd
    end if
    if theTextDate is not "" then
        set theText to theText & " due " & theTextDate
    end if
    parse sentence (theText) with add immediately
end repeat
end tell