Re: iCal script using cal name?
Re: iCal script using cal name?
- Subject: Re: iCal script using cal name?
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 12 Jan 2004 11:40:28 -0800
On 1/12/04 10:34 AM, "David A. Cox" <email@hidden> wrote:
>
As part of a larger task, I am trying to turn all the "allday" events in
>
an iCal calendar to normal events, and I want to do this by referencing
>
the calendar's title, or possibly even the fact that it was updated just
>
seconds before this command. So far, I have only been able to do this by
>
referencing the number fo the calendar. Anyone know how to do this same
>
script, but using the title fo the calendar rather than its number?
Although 'calendar' class has a 'title' property, you cannot specify it by
title. Here's what the 'application' class says about 'calendar' as an
element of the application:
calendar by numeric index, before/after another element, as a range of
elements, satisfying a test
No 'by title', or 'by name' there. (This may be intentional, for some reason
I can't fathom. The same thing occurs with 'event' as an element of
'calendar': no 'by summary' or 'by name'. It may be why none of these
classes has a 'name' property. In the case of events and todos I understand
the reason: there can be many, many events and todos with the same name, so
this practice forces you to find other ways of specifying the one you have
in mind - perhaps by start date as well as summary. In the case of calendar,
I don't understand it at all: who's going to have more than one calendar
with the same name?)
You'll notice ' satisfying a test ': that means you can use a whose clause.
Here's how to do it. Note you're going to have to create a start time and
end time. Then you run into iCal's idiotic bug with AppleScript times being
actually set as GMT. The script below actually needs a more complicated
handler to deal with dates that aren't in the same "daylight savings time"
part of the year as you are when you run the script (when time to GMT is
different by an hour than what it is today). But it will give you the idea.
set timeToGMT to time to GMT
tell application "iCal"
set theCalendar to first calendar whose title is "Whatever"
tell theCalendar
repeat with theEvent in every event
if theEvent is allday event then
set midnight to ((start date of theEvent) - timeToGMT)
set allday event of theEvent to false
set start date of theEvent to (midnight + (9 * hours))
set end date of theEvent to (midnight + (10 * hours))
end if
end repeat
end tell
end tell
>
>
tell application "iCal"
>
repeat with theEvent in events of calendar 1
>
if theEvent is allday event then
>
set allday event of theEvent to false
>
end if
>
end repeat
>
>
end tell
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.