I have an event in ical that recurs every day.

I would like to randomize the start time of this event (which schedules an applescript) so that the start times are random but within 30 min of each other.

I've done google and duckduck searches for:

  • randomize ical event start time;
  • randomize ical events by 5 minutes,

and have gotten nothing relevant.

I've had a look at the applescript dictionary for iCal but cannot find a useful function.

I don't need the whole script just a hint in the right direction or a function that I could use to create the events instead of modifying them all by hand.

1 Answer 1


I found the answer googling for applescript make start time random.

I used the following code from this apple support community thread:

tell application "TextEdit"
delay (random number from 2 to 8)
set textToType to "text" & some item of {"hello", "goodbye"} & text
end repeat
end tell

and for text:

some item of {"blue", "red"}

Here is the final script that worked for me:

tell application "iCal"

    set myCal to "Scheduled tasks"
    set allEvents to every event in calendar myCal
    repeat with anEvent in allEvents
        set modTime to (random number from 0 to 30)
        display dialog modTime with title start date of anEvent as text
        set newStartTime to (start date of anEvent) + modTime * minutes
        set start date of anEvent to newStartTime
        set (end date of anEvent) to ((end date of anEvent) + modTime * minutes)
    end repeat
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .