tinyapps.org / blog

iCal: Delete all events before or after a certain date via AppleScript #

This script deletes all events before (or after - see below) a given date in a specified calendar.
Backup your calendar(s) before running this script!!!
tell application "iCal" -- "iCal" will automatically change to "Calendar" when compiled under Mountain Lion
tell calendar "foo" -- Change this to the name of the calendar you want to modify
set x to events whose start date < date "Friday, January 1, 1971 00:00:00"
(* Replace < with > to get events after the specified date instead of before *)
(* Replace "Friday, January 1, 1971 00:00:00" with desired date in m/d/year format (e.g., "1/1/2010") - it will automatically expand when the script is compiled. *)
repeat with i in x
delete i
end repeat
end tell
end tell

Script formatting generated with Tetsuro Kurita's handy AppleScriptHTML.

See also: iCal cleaning and iCal: Highlight & delete all events or events within a date range.

/mac | Aug 28, 2013

Subscribe or visit the archives