Calendar, import and delete

After I have imported (multitimes) an ics calandar into my google calendar, and it was a tedious work to removes all event that corresponds to this import.

I found a simple and efficient solution to delete them all with google script. Fortunatly the events share a common description, which allow to get them by search.
Another possibility would have to search them by creation date.

function deleteSomeEvents(){
    var start = new Date("September 1, 2014");
    var end = new Date("December 31, 2015");
    var events = CalendarApp.getDefaultCalendar().getEvents(start, end, {search: 'something that I want to delete'});
    Logger.log('Number of events: ' + events.length);
    for(var i =0; i< events.length;i++){
        Logger.log( events[i].getStartTime()+" "+events[i].getTitle());
        //events[i].deleteEvent();
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *