Skip to content

Instantly share code, notes, and snippets.

@drdrang
Last active July 6, 2021 13:19
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save drdrang/480831c3eb35d5a66b5d681e881bdef3 to your computer and use it in GitHub Desktop.
Save drdrang/480831c3eb35d5a66b5d681e881bdef3 to your computer and use it in GitHub Desktop.
AppleScript to delete all reminders more than 30 days old.
set remindersOpen to application "Reminders" is running
set monthAgo to (current date) - (30 * days)
tell application "Reminders"
set myLists to name of every list
repeat with thisList in myLists
tell list thisList
delete (every reminder whose completion date is less than monthAgo)
end tell
end repeat
if not remindersOpen then quit
end tell
@LunnSon
Copy link

LunnSon commented May 8, 2018

Excuse my ignorance but how would you execute this script?

@ericharley
Copy link

ericharley commented Jun 5, 2018

Copy/paste the script into the "Script Editor" application (Applications -> Utilities), press play.

Or you could save this to a file, "Purge Old Reminders.scpt," and then from Terminal use the command line program osascript,

osascript "Purge Old Reminders.scpt"

You'll be asked to grant Terminal permission to access your Reminders.

@MacularDegenerate
Copy link

Any way to execute this from a Windows PC or directly from iPhone?

@drdrang
Copy link
Author

drdrang commented Apr 23, 2020

There are ways to trigger AppleScripts from an iPhone, but you definitely have to have a Mac in order to run the AppleScript.

@NEOdinok
Copy link

Is this script permanently activated upon pressing "play" button in script editor? If so, how do you disable it afterwards? @drdrang

@drdrang
Copy link
Author

drdrang commented Nov 17, 2020

Like all AppleScripts, it runs until it's finished or encounters an error. But there's nothing in the script that causes it to run repeatedly. If it is running for a long time for you, chances are you have a huge number of completed reminders. I've learned since writing this script that AppleScript sometimes takes a ridiculously long time to process the every reminder whose clause. If that's what your question is about, you can stop the process in Script Editor by pressing the Stop button (black square) near the upper left corner.

@NEOdinok
Copy link

If anyone has issues with this script try changing 30 to 1 in the second line so that is deletes the tasks no matter how long ago you deleted them.

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