Skip to content

Instantly share code, notes, and snippets.

@freklov
Last active April 1, 2017 20:54
Show Gist options
  • Save freklov/ac069cf904aafc78c47d9555aa5aa165 to your computer and use it in GitHub Desktop.
Save freklov/ac069cf904aafc78c47d9555aa5aa165 to your computer and use it in GitHub Desktop.
AppleScript for Things: Copy Things to dos in list "Today" to a list in Apple's Reminders
# things-today_reminders freklov 04/01/2017 a
# Copy Things to dos in list "Today" to a list in Apple's Reminders
#
# ATTENTION
# if two reminders lists with the same name exist, it is not forseeable which list is choosen
#
# Restrictions
# projects in today list are not extracted
#
set remindersList to my chooseRemindersList()
if remindersList is not missing value then
set thingsOfToday to {}
tell application "Things"
repeat with thingsToDo in to dos of list "Today"
if status of thingsToDo is open then
set thingsName to name of thingsToDo
if exists project of thingsToDo then
set thingsName to thingsName & " [" & (name of project of thingsToDo) & "]"
end if
copy thingsName as text to end of thingsOfToday
end if
end repeat
end tell
tell application "Reminders"
repeat with tot in thingsOfToday
tell remindersList to make new reminder at end with properties {name:tot}
end repeat
end tell
end if
on chooseRemindersList()
set returnValue to missing value
set listNames to {}
tell application "Reminders"
repeat with remindersList in lists
copy name of remindersList as text to end of listNames
end repeat
choose from list listNames ¬
with title "Choose Reminders List"
if result is not false then
set returnValue to list (first item of result as text)
set theReminderCount to my countActiveReminders(returnValue)
if theReminderCount > 0 then
display alert (name of returnValue as text) ¬
message "The selected list has " & theReminderCount & " uncompleted reminders." as warning ¬
buttons {"Cancel", "Keep untouched", "Mark completed"} ¬
default button "Mark completed" cancel button "Cancel"
if button returned of result = "Mark completed" then
my markAllRemindersCompleted(returnValue)
end if
end if
end if
end tell
return returnValue
end chooseRemindersList
on markAllRemindersCompleted(remindersList)
tell application "Reminders"
repeat with theReminder in reminders of remindersList
if completed of theReminder = false then set completed of theReminder to true
end repeat
end tell
end markAllRemindersCompleted
on countActiveReminders(remindersList)
set returnValue to 0
tell application "Reminders"
repeat with theReminder in reminders of remindersList
if completed of theReminder = false then set returnValue to returnValue + 1
end repeat
end tell
return returnValue
end countActiveReminders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment