• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Determining the default CalendarName in Calendar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining the default CalendarName in Calendar


  • Subject: Re: Determining the default CalendarName in Calendar
  • From: Bill Vlahos <email@hidden>
  • Date: Tue, 19 May 2015 07:27:18 -0700

Nigel,

Thank you. This works.

Bill Vlahos

> On May 17, 2015, at 5:32 AM, Nigel Garvey <email@hidden> wrote:
>
> Bill Vlahos wrote on Sat, 16 May 2015 11:46:33 -0700:
>
>> AppleScript can create a calendar event using the following code.
>>
>> tell application "Calendar"
>> 	activate
>> 	tell (first calendar whose name is calendarName)
>> 		set vEventInfo to make new event at end of events with properties
>> {summary:theSummary, start date:startDate, end date:endDate,
>> description:theDescription, location:theLocation}
>>
>> How can I remove the requirement to specify the calendarName and have it
>> just use whatever is set as the default calendar in the Calendar
>> application?
>
> Hi.
>
> This seems to work:
>
>  -- Read and analyse Calendar's preferences, returning the default calendar's ID.
>  -- The sed code outputs the CalDefaultCalendar value if it's quoted (ie. an ID); otherwise the "last selected calendar list item" value.
> -- The line containing the latter value is stored and used only if no
> CalDefaultCalendar value is returned first.
>  set defaultCalendarID to (do shell script "defaults read com.apple.iCal | sed -En '
>  /^.+CalDefaultCalendar [^\\\"]+\\\"([^\\\"]+).+/ { s//\\1/p ; q ; }
>  /last selected calendar list item/ h
>  $ { g ; s/^[^=]+[^\\\"]+\\\"([^\\\"]+).+$/\\1/p; }'")
>
>  tell application "Calendar"
>    set defaultCalendar to calendar id defaultCalendarID
>    name of defaultCalendar -- Test.
>  end tell
>
>
> NG
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


References: 
 >Re: Determining the default CalendarName in Calendar (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: Applescript coding
  • Next by Date: Re: Determining the default CalendarName in Calendar
  • Previous by thread: Re: Determining the default CalendarName in Calendar
  • Next by thread: month contants and dates...
  • Index(es):
    • Date
    • Thread