AppleScript将特定的iCal事件移动一周

时间:2012-11-09 13:41:20

标签: events date applescript move icalendar

我根据特定的开始日期为6周内的各个客户安排了iCal活动。即客户1,2和3在下周一开始,我在6周的时间内设置了几个iCal事件,这将触发其他不同的AppleScripts等。(工作正常,但......)

如果客户2决定比1和3晚1周后继续该计划并且我已经安排了他的活动,我如何在iCal for Client 2中选择已经创建的活动并将它们全部移动一周? / p>

这是我到目前为止所得到的:

tell application "Calendar"
tell calendar "ExampleCalendar"
set theEventList to every event whose summary contains "Client2"
end tell
end tell

这将选择事件,现在如何将它们全部移动一周(它们显然都有不同的开始日期,并且间隔不等)

这会让我的生活更轻松!谢谢。

1 个答案:

答案 0 :(得分:1)

更新

Yosemite用户现在可以reference selected Calendar events in AppleScript

尝试:

set daysAdded to 7

tell application "iCal"
    tell calendar "ExampleCalendar"
        set theEventList to every event whose summary contains "Client2"
        repeat with anEvent in theEventList
            tell anEvent
                set it's end date to (it's end date) + daysAdded * days
                set it's start date to (it's start date) + daysAdded * days
            end tell
        end repeat
    end tell
end tell

这是另一种方法。

        tell anEvent
            set {sDate, eDate} to {(it's start date), (it's end date)}
            set it's start date to sDate + daysAdded * days
            set it's end date to eDate + daysAdded * days
        end tell