#!/usr/bin/osascript on run argv set daysToFetch to 7 if (count of argv) > 0 then set daysToFetch to (item 1 of argv) as integer end if set currentDate to current date set endDate to currentDate + (daysToFetch * days) tell application "Calendar" set output to "" set allCalendars to calendars repeat with aCal in allCalendars set calName to name of aCal -- Filter out holidays or subscription calendars if they are too noisy, but for now keep all. set calEvents to (every event of aCal whose start date is greater than or equal to currentDate and start date is less than or equal to endDate) repeat with anEvent in calEvents try set evtSummary to summary of anEvent on error set evtSummary to "No Title" end try try set evtStart to start date of anEvent on error set evtStart to "Unknown" end try try set evtEnd to end date of anEvent on error set evtEnd to "Unknown" end try try set evtLoc to location of anEvent if evtLoc is missing value then set evtLoc to "" on error set evtLoc to "" end try set output to output & "Calendar: " & calName & "\nEvent: " & evtSummary & "\nStart: " & evtStart & "\nEnd: " & evtEnd & "\nLocation: " & evtLoc & "\n---\n" end repeat end repeat if output is "" then return "No events found for the next " & daysToFetch & " days." else return output end if end tell end run