-
-
Save ngabyn/4cca9009d29f2ccd69d8d8d6c28f4cef to your computer and use it in GitHub Desktop.
Revisions
-
Eric Koleda revised this gist
Oct 16, 2018 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,9 @@ * You must enable the Calendar Advanced Service: * https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services */ function moveEvents(eventTitle, fromCalendarName, toCalendarName) { var fromCalendarId = CalendarApp.getCalendarsByName(fromCalendarName)[0].getId(); var toCalendarId = CalendarApp.getCalendarsByName(toCalendarName)[0].getId(); var now = new Date(); var oneYearAgo = new Date(now); @@ -28,5 +28,5 @@ function moveEvents(eventTitle, destinationCalendarName) { } function test() { moveEvents('Gym', 'Medical', 'Exercise'); } -
Eric Koleda created this gist
Oct 16, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ /** * Move events with a given title from your primary calendar to another calendar. * You must enable the Calendar Advanced Service: * https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services */ function moveEvents(eventTitle, destinationCalendarName) { var fromCalendarId = CalendarApp.getDefaultCalendar().getId(); var toCalendarId = CalendarApp.getCalendarsByName(destinationCalendarName)[0].getId(); var now = new Date(); var oneYearAgo = new Date(now); oneYearAgo.setYear(oneYearAgo.getYear() - 1); var pageToken = null; do { var results = Calendar.Events.list(fromCalendarId, { q: eventTitle, pageToken: pageToken }); results.items.filter(function(event) { return event.summary == eventTitle; }).forEach(function(event) { Calendar.Events.move(fromCalendarId, event.id, toCalendarId); console.log('Moved event ' + event.id); }); pageToken = results.nextPageToken; } while (pageToken) } function test() { moveEvents('Gym', 'Exercise'); }