MacOS Automator Script to Summarize your Calendar Day

I don’t like the layout of most calendar apps, and I want to be able to make notes, mark things as done, scribble etc. So, I built an automator script to export all of my calendar events and reminders for the day into a text file. I’m on Mac, so I used Automator for this.

To start, I created a new Application in Automator – just open automator, and create an Application.

Here’s the structure of the workflow used in the app. Below, I’ll provide the details for each step.

All of the actions used can be found in the ‘Actions‘ Library in the left navigation bar in automator – you can just search for them by name.


The first script is an unfortunately necessary hack – I found that Automator struggles to ask MacOS for permissions to read calendars and Reminders, and needs a bit of help by triggering that request with some AppleScript. Add the following ‘Run ApplesScript‘ action.

Here’s the code to copy/paste:

on run {input, parameters}
	
	(* literally just doing this to get calender/reminder permissions prompt as using the native calendars action doesn't do it for some reason *)
	tell application "Calendar"
		set calendarList to calendars
	end tell
	tell application "Reminders"
		set reminderLists to lists
	end tell
	
end run

When the script runs in the final App, the user will be asked to grant permission for it to access their Calendar and reminder. The next step in the Automator workflow is to find all events in the calendar that start in the next day. This will pull all events from all calendars in the Apple calendars app.

Important note: Due to the hack above, this step needs to ignore the previous action’s input (we don’t actually want the data it gathers, we just wanted to get those permissions), which can be checked under ‘Options‘.

Add the following ‘Find Calendar Events‘ action.

Next, just add an ‘Events Summary‘ action – there’s nothing to configure for this one, it just takes the details of the events from the previous action and formats them.

Now add a ‘Set the Value of Variable‘ action and set the Variable name to ‘cal‘ – this will save the output of the last action into a named variable for later use.

That takes care of the calendars. If you want to include reminders as well, add a ‘Find Reminders‘ action, followed by another ‘Event Summary‘ action to format the reminders output, and then another ‘Set Value of Variable‘ action, assigning the reminders to the variable ‘rem‘.

Now we want to assemble the data collected. Add two ‘Get Value of Variable‘ actions, the first for the ‘cal‘ (calendar output) variable and the second for the ‘rem‘ (reminders output) variable. For the first of these, check ‘Ignore this action’s input‘ so that no other data other than what was placed in these variables is hanging about.

Next, add a ‘Run Shell Script‘ action. Use the ‘Shell‘ dropdown to select ‘/bin/bash‘ and then enter the script code. This code takes the output of the two variables above in the order they were retrieved (variables $1 and $2 and echo’s them with today’s date (date +’%d-%m-%Y’).

Here’s the code to copy/paste:

echo "TODAYS THINGS"
date +'%d-%m-%Y'
echo "---------------"
echo "$1"
echo "---------------"
echo "$2"

Finally add a ‘New TextEdit Document‘ action. There’s nothing to configure for this action, output of the above script will just be sent to it.

You can test the script by clicking ‘Run‘ in the top right corner of the Automator window, and then save your app and move it to your Applications folder. When you run it, you’ll get something like this:

Handy!

Troubleshooting: I have noticed that sometimes after editing the script it again loses permissions for the Calendars and Reminders apps. Toggling those permissions in system preferences for the script resolves this.

Leave a Reply