Last active
September 4, 2024 17:43
-
-
Save michaelwhyte/4413b30dcb481b1c137f52a3ffa158f2 to your computer and use it in GitHub Desktop.
Bulk delete Google calendar events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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