Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save freklov/47b09a7c653c88ac66163df895352d30 to your computer and use it in GitHub Desktop.
Save freklov/47b09a7c653c88ac66163df895352d30 to your computer and use it in GitHub Desktop.
AppleScript: Delete completed reminders from from a dedicated list of Apple's Reminders
# reminders-delete_completed freklov 04/01/2017
# Delete completed reminders from from a dedicated list of Apple's Reminders
#
# ATTENTION
# if two reminders lists with the same name exist, it is not forseeable which list is choosen
#
# Fork from
# https://gist.github.com/poritsky/8d8aec063216ed16b9b5
#
my chooseListeAndDeleteReminders()
on chooseListeAndDeleteReminders()
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 remindersList to list (first item of result as text)
set theReminderCount to my countCompletedReminders(remindersList)
if theReminderCount > 0 then
display alert (name of remindersList as text) ¬
message "The selected list has " & theReminderCount & " completed reminders." as warning ¬
buttons {"Cancel", "Delete Completed"} ¬
default button "Delete Completed" cancel button "Cancel"
if button returned of result = "Delete completed" then
my deleteCompletedReminders(remindersList)
end if
end if
end if
end tell
end chooseListeAndDeleteReminders
on deleteCompletedReminders(remindersList)
tell application "Reminders"
tell remindersList
delete (every reminder whose completed is true)
end tell
end tell
end deleteCompletedReminders
on countCompletedReminders(remindersList)
set returnValue to 0
tell application "Reminders"
repeat with theReminder in reminders of remindersList
if completed of theReminder = true then set returnValue to returnValue + 1
end repeat
end tell
return returnValue
end countCompletedReminders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment