06/24/13 19:30:10

Drafts' "List To Reminders" on your Mac

One of the best things Drafts 3 (iPhone, iPad) implemented was the ability to talk to Reminders. Drafts comes with a nifty “List to Reminders” feature, which I use at least once a week to for my shopping list.

Since we don’t have Drafts on our Macs, I thought a more universal solution would be the best approach. Instead of taking text from a file, this script uses text lines from your clipboard.

It has the same feature that Drafts uses to put Reminders on a non-default Reminders list. Simply write an exclamation mark followed by the name of the Reminders list to use in the first line.

Cottage Cheese

You can modify the script to close Reminders immediately afterwards, but since AppleScript has to open Reminders I thought it would be better to ask the user if Reminders should be closed again. The reasoning here is that Reminders would just pop up and immediately close, which feels a bit weird (like, “what just happened?”). So, the script asks to quit Reminders. The default is Yes.

(Gist version)

-- get clipboard and separate lines
set clipboardText to the clipboard as text
set reminderLines to paragraphs of clipboardText
set defaultRemindersList to "Shoppinglist"

-- figure out if a non-default reminder list should be used
if item 1 of reminderLines starts with "!" then
    -- set other reminder list and delete first line
   set remindersList to characters 2 thru -1 of item 1 of reminderLines as text
   set reminderLines to items 2 thru -1 of reminderLines
    set remindersList to defaultRemindersList
end if

tell application "Reminders"
   -- create reminders
    tell list remindersList
        repeat with currentReminderLine in reminderLines
           make new reminder with properties {name:currentReminderLine as text}
       end repeat
 end tell

end tell

-- optionally quit Reminders
tell application "System Events"
   set quitReminders to display dialog "Quit Reminders?" buttons {"No", "Yes"} default button "Yes"
   if button returned of quitReminders is equal to "Yes" then
     tell application "Reminders" to quit
   else if button returned of quitReminders is equal to "No" then
     -- if no is clicked, system events would still be active, so
       -- let's activate Reminders again
      tell application "Reminders" to activate
   end if

end tell