I have a scenario where I want to change the end date of a event, so that we can see how long this event took. I can add a start and end time with the script below, but this is not a true reflection of the process. So what I need is to be able to find the event and then change its end time.
Any ideas.
tell application "iCal"
set thedate to current date
activate
if not (exists calendar "TESTING") then
create calendar with name "TESTING"
end if
tell calendar "TESTING"
make new event at end of events with properties {summary:"TESTING", start date:thedate, end date:(thedate + 720)}
end tell
end tell
Hi,
If you have given a specific name for your event (or summary) then you could identify that event and extract its end date property.
Below is a simple script that pulls out a specific event that I created in iCal and named it “Start Safari”. The script extracts the “Start Safari” event and gives the start date and end date accordingly. Once you have these data, you should be able to change them programmatically.
tell application "iCal"
activate
set thisCalendar to "Home"
set i to 0
repeat with i from 1 to count of events of calendar thisCalendar
set thisEvent to event i of calendar thisCalendar
if summary of event i of calendar thisCalendar is equal to "Start Safari" then
beep
display dialog "This is the start date of this event: " & start date of thisEvent --returns start date of thisEvent
display dialog "This is the end date of this event: " & end date of thisEvent --returns end date of thisEvent
end if
end repeat
end tell
Good luck.
archseed
many thanks.
that helped massively.
Here is the code
tell application "iCal"
set thedate to current date
set thiscal to "yourcalendar"
repeat with i from 1 to count of events of calendar thiscal
set thisevent to event i of calendar thiscal
if summary of event i of calendar thiscal is equal to "eventname" then
set end date of event i of calendar thiscal to (thedate + 13600)
display dialog "the end date is:" & end date of thisevent
end if
end repeat
end tell