Applescript and iCal interaction

匆匆过客 提交于 2019-12-03 20:23:50

I've been grappling with this today and found that you can filter by date (at least on Snow Leopard). So

tell application "iCal"
    set out to ""
    set todaysDate to current date
    set time of todaysDate to 0
    repeat with c in (every calendar)
        set theEvents to (every event of c whose start date ≥ todaysDate)
        repeat with current_event in theEvents
            set out to out & summary of current_event & "\n"
        end repeat
    end repeat
    return out
end tell

will return the summary of all future events, and very quickly, compared to iterating through all events.

It isn't AppleScript, but the best of the bunch of other ways to do this seems to be iCalBuddy, which uses the public Cocoa APIs rather than parsing the calendar file directly and handles repeating events sensibly.

icalBuddy -nc -eed -iep title,datetime eventsToday+1

My initial intent was to select only the events for a given date, but apparently there aren't methods in iCal to access only the events for a specific day.

Thus, it is always necessary to go over all the events registered in every calendar. Even when interested in the events of a single calendar, say 'Today's Meetings", it is necessary to go through the entire set of events.

The best alternatives I've found around in the web don't use Apple Script, but instead they process the 'ics' files where the info is actually stored.

For reference, those files are located in '~/Library/ApplicationSupport/iCal'.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!