AppleScript for iCal events from Address Book entries

applescriptcontactsical

I want to create a script that creates alarmed events in iCal for birthdays of people that I have in my address book. Unfortunately, I am very bad working with AppleScript.

Below is the outline of what I it to do, I would love some help as to what the actual script should be.

  • run script when a change is made to a birth date in address book or when address book quits
  • define list of people (will have an extra alarm, see below)
  • search for birthdays entered in address book
  • if no event is present in ical calendar named "birthdays" for birthdays found in address book (check name and date)
    • create new all day event in birthday calendar with alarm on date and title "(Name of person)'s Birthday)
  • if birthday is on list defined earlier
    • add extra alarm two weeks before the birthday
  • display message showing what new events were created when the script ran

I don't think the script would be that complex or long. Any help would be very much appreciated.

I'm not sure how this script could be triggered, but ideally it would run if a change is made to a birthday in address book (or a new one added).

Best Answer

To set single alerts on all birthdays, you can avoid a script altogether:

  1. Open Calendar Preferences in Calendar.
  2. Under General, tick "Show Birthdays calendar".
  3. Under Alerts, set an alert for "Birthdays".

I haven't taken the time to actually write up an AppleScript for the double alarm parts, but this article seems to cover scripting calendar alarms quite nicely. I would imagine you would just need to create a file or list in the script that contains the names of the events (which you can deduce from the standard naming convention Calendar app uses).

Also I am using Mountain Lion with Calendar app. I can't recall if the steps above work on older versions of iCal.