Making a list of available appointment times from Calendar, by day

I would like to find a way to output a list of available appointments from Calendar, based on selecting a date or range of dates, and being able to specify the calendars that I want to pull appointment data from.

The output should be something like this, that can be emailed or texted.
I am free on 7/28/17 between:
Start of day - 7:00 AM
7:15 AM - 9:30 AM
10:00 AM - 10:30 AM
12:00 PM - End of day

I found pretty much what I wanted in Workflow, an automation tool is iOS, but wondered if there was a way to accomplish this using AppleScript and KM. (workflow.is is their url)

A few screen captures are below of that workflow. I looked for a Calendar AppleScript dictionary, but did not find one. I use BusyCal, and found some documentation https://support.busymac.com/help/70621-url-handler but since all my appointments are replicated in Calendar, it might be easier.

Any suggestions would be welcome.

Actually, I think Calendar provides good support for scripting.
You might do a Google search on "applescript calendar", where you will find a number of hits.

In particular you might be interested in CalendarLib. This is a script library, with examples, written by @ShaneStanley. Although I have not used this particular library, I can vouch for Shane as being one of the world's best, most experienced, AppleScript developer.

Sorry I can't offer more, but I rarely use Apple Calendar.
Good luck, and let us know how it goes.

I finally got around to this, finding a fantastic applescript by Nigel Garvey at https://macscripter.net/viewtopic.php?id=41273&p=2

Get Calendar Events w Script.kmmacros (10.8 KB)

that uses the library mentioned by @JMichaelTX. It got me most of the way, outputting a text file of all my appointments, but not my available times (the space between appointments). I created a macro to parse the output to give me the available times.

Parse String of Calendar Events.kmmacros (9.3 KB)

Next steps are to modify to use AM/PM for times and also to ask user input for Timezone to adjust the available times. Any suggestions on how to improve are helpful! Also noted that the last day I am not getting the last available slot due to my logic if comparing present day vs yesterday, but I can live with that for now.

The output is currently like this:
This is my current availability, in Mountain Time:

Tuesday, April 23, 2019:
— Start of Day - 11:00
— 12:00 - 14:30
— 15:00 - 18:20
— 19:05 - End of Day
Thursday, April 25, 2019:
— Start of Day - 08:00
— 09:00 - 12:00
— 13:00 - 13:00
— 15:00 - 15:00
— 16:00 - End of Day
Friday, April 26, 2019:
— Start of Day - 07:00
— 07:30 - 12:00
— 14:00 - End of Day
Saturday, April 27, 2019:
— Start of Day - 17:00
— 19:30 - End of Day
Monday, April 29, 2019:
— Start of Day - 11:00
— 12:30 - End of Day
Tuesday, April 30, 2019:
— Start of Day - 08:00
— 09:00 - 12:00
— 13:00 - End of Day
Wednesday, May 1, 2019:
— Start of Day - 13:30
— 14:00 - 13:30
— 14:00 - 14:30
— 15:30 - End of Day
Thursday, May 2, 2019:
— Start of Day - 13:30
— 14:30 - 13:30
— 14:30 - End of Day
Monday, May 6, 2019:
— Start of Day - 11:00
— 12:30 - End of Day
Wednesday, May 8, 2019:
— Start of Day - 10:00
— 11:00 - 14:30:

3 Likes