LoginSignup
0
0

More than 3 years have passed since last update.

GAS Calendarの予定削除

Last updated at Posted at 2020-07-02

GAS Calendarの予定削除


カレンダーを全て取得して
ある日程から先の予定を全て削除する。

Exceptionエラーとなり、操作できないと表示されるが
何度か繰り返すと予定は削除された。

コード.gs
function Delete_CalendarEvents() {

  var calendars = CalendarApp.getAllCalendars();

  const startTime = new Date('2020/7/3 7:00:00');
  const endTime = new Date('2021/1/1 12:00:00');

  for (var i in calendars) {
    var id = calendars[i].getId();
    var calendar = CalendarApp.getCalendarById(id);
    //Logger.log(id)
    var events = calendar.getEvents(startTime, endTime);
    for (var i in events) {
      var event = events[i];

      event.deleteEvent();
    }
  }
}

7/8追記


複数の予定があると例外エラーとなって使い物にならず

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0