Skip to content

Instantly share code, notes, and snippets.

@michaelwhyte
Last active September 4, 2024 17:43
Show Gist options
  • Save michaelwhyte/4413b30dcb481b1c137f52a3ffa158f2 to your computer and use it in GitHub Desktop.
Save michaelwhyte/4413b30dcb481b1c137f52a3ffa158f2 to your computer and use it in GitHub Desktop.
Bulk delete Google calendar events
function delete_events()
{
// Copy and Paste this script at https://script.google.com and then run it
// This script modified from code found at this Stackoverflow question and answer:
// https://webapps.stackexchange.com/questions/19513/how-to-delete-all-events-on-many-dates-all-at-once-but-not-the-whole-calendar-in
var fromDate = new Date(1995,0,1,0,0,0);
var toDate = new Date(2015,0,1,0,0,0);
var calendarName = 'Put Your Google Calendar Name Here';
// delete from Jan 1 to end of Jan 4, 2013 (for month 0 = Jan, 1 = Feb...)
var calendar = CalendarApp.getCalendarsByName(calendarName)[0];
var events = calendar.getEvents(fromDate, toDate);
for(var i=0; i<events.length;i++){
var ev = events[i];
Logger.log(ev.getTitle()); // show event name in log
ev.deleteEvent();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment