Skip to content

Instantly share code, notes, and snippets.

@Jayphen
Created July 27, 2012 12:18
Show Gist options
  • Save Jayphen/3187630 to your computer and use it in GitHub Desktop.
Save Jayphen/3187630 to your computer and use it in GitHub Desktop.
A script for quickly adding reminders to the Reminders app in Mountain Lion from Launchbar. Save this as a .scpt and drop it in ~/Library/Application\ Support/LaunchBar/Actions
on handle_string(str)
set arrayWithDate to my theSplit(str, "@")
if arrayWithDate's length > 1 then
set theDate to my parseDate(getArrayValue(arrayWithDate, 2))
end if
set arrayWithBody to my theSplit(getArrayValue(arrayWithDate, 1), "#")
if arrayWithBody's length > 1 then
set reminderBody to my getArrayValue(arrayWithBody, 2)
else
set reminderBody to ""
end if
set reminderName to getArrayValue(arrayWithBody, 1)
tell application "Reminders"
set listName to list "Inbox"
try
set newReminder to make new reminder with properties {name:reminderName, container:listName, body:reminderBody, remind me date:theDate}
on error
set newReminder to make new reminder with properties {name:reminderName, container:listName, body:reminderBody}
end try
end tell
end handle_string
on theSplit(theString, theDelim)
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to theDelim
set theArray to every text item of theString
set AppleScript's text item delimiters to oldDelimiters
return theArray
end theSplit
on getArrayValue(array, location)
return item location in array
end getArrayValue
on parseDate(theDate)
set date_string to theDate
set date_elements to every word of date_string
set the_date to current date
set {time of the_date, day of the_date} to {0, 1}
set month of the_date to (item 2 of date_elements) as integer
try
set day of the_date to (item 1 of date_elements) as integer
set year of the_date to (item 3 of date_elements) as integer
set time of the_date to (item 4 of date_elements) * 3600
set time of the_date to (time of the_date) + (item 5 of date_elements) * 60
set time of the_date to (time of the_date) + (item 6 of date_elements)
end try
the_date
end parseDate
@Jayphen
Copy link
Author

Jayphen commented Jul 27, 2012

I've edited this script so you can now enter reminders in the format:

title of the reminder #some notes @29/07/2012 16:45

The date must be roughly in the above format (will also accept 29-7-12, but not 29th July or 'tomorrow'), and the date must be 24-hr time.

Notes & reminder date are optional.

@jgclark
Copy link

jgclark commented Feb 27, 2015

Seems not to work under OS X 10.10: problem in setting list names. I've tried "set listName to list whose name is "Inbox"" but that doesn't seem to work either.

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