Deleting all of events manually is impossible, and for some reason I did not have the ease of using "delete all events of this type" option, therefore only option I am left with using google calendar api for this task. I have not use calendar api before therefore I have to study before using it. While I am doing that thought to document the process so that I can publish it as a blog post.
http://code.google.com/apis/calendar/data/1.0/developers_guide_python.html
I used Google Calendar API from above link and checked out source from mercurial. All I used is calendarExample.py and modified it to do my task.
What I wanted to do is search for “Tasks” (the events RTM has created called tasks) in whole calendar and delete all of those items, thus I created a search query which search “Tasks” and then delete all items in that query.
Please note that following code is only a modification of
http://code.google.com/p/gdata-python-client/source/browse/samples/calendar/calendarExample.py
Python Code Snippet.
def FullTextQuery(email, password, text_query='Tennis'):
cal = gdata.calendar.service.CalendarService()
cal.email = email
cal.password = password
cal.source = 'Google-Calendar_Python_Sample-1.0'
cal.ProgrammaticLogin()
print 'Full text query for events on Primary Calendar: \'%s\'' % ( text_query,)
query = gdata.calendar.service.CalendarEventQuery('default', 'private', 'full', text_query)
# This is the range that we search.
query.start_min = '2009-09-05'
query.start_max = '2050-09-10'
feed = cal.CalendarQuery(query)
for i, an_event in enumerate(feed.entry):
print '\t%s. %s' % (i, an_event.title.text,)
print '\t\t%s. %s' % (i, an_event.content.text,)
for a_when in an_event.when:
print '\t\tStart time: %s' % (a_when.start_time,)
print '\t\tEnd time: %s' % (a_when.end_time,)
if an_event:
cal.DeleteEvent(an_event.GetEditLink().href)
def main():
while(1):
print "deleteing events"
# Give your email and password here.
FullTextQuery(email, password, "Tasks")
time.sleep(5)
if __name__ == '__main__':
main()