You need to have wget, tidy, grep.
To get authentication:
wget -q -O- --post-data 'Email=username@gmail.com&Passwd=passwd&service=cl&source=Gulp-CalGulp-1.05' https://www.google.com/accounts/ClientLogin
Note that Auth=XXX field that comes back.
To request the feed (you can play with start-min, start-max, and max-results):
wget -q -O- --header='Authorization: GoogleLogin auth=XXX' http://www.google.com/calendar/feeds/default/private/full?start-min=2000-01-01T00:00:00&start-max=2040-01-01T23:59:59&max-results=1000
Note the edit URI's of the events you'd like to delete:
wget ... | tidy -xml -wrap 999 | grep edit
Delete the event by using its edit URI; this is a two step process, because wget does not redirect correctly:
wget -nv -O- --header='Authorization: GoogleLogin auth=XXX' --header='X-HTTP-Method-Override: DELETE' --post-data='' 'URI'
Watch the output and note the redirect URI with gsessionid attached, then execute:
wget -nv -O- --header='Authorization: GoogleLogin auth=XXX' --header='X-HTTP-Method-Override: DELETE' --post-data='' 'URI?gsessionid=YYY'
Related link
May 07, 2006
Subscribe to:
Post Comments (Atom)
9 comments:
Thank you - very useful!
Thanks for this, it saved me from manually deleting over 2000 entries. In return, here is a bash script to do everything in one go.
# set up user parameters
guser=YourGmailUsername@gmail.com
gpass=YourGmailPassword
minTime=2008-07-18T12:29:00
maxTime=2008-07-18T12:29:59
maxResults=2
# login and get the auth token
authToken=`wget -q -O- --post-data 'Email='${guser}'&Passwd='${gpass}'&service=cl&source=Gulp-CalGulp-1.05' https://www.google.com/accounts/ClientLogin | grep Auth | awk '{print substr($0, 6) }'`
# get all events that match criteria and delete them one by one
wget -v -O- --header="Authorization: GoogleLogin auth="${authToken} "http://www.google.com/calendar/feeds/default/private/full?start-min="${minTime}"&start-max="${maxTime}"&max-results="${maxResults} |
tidy -q -xml -wrap 999 |
grep edit |
awk '{ system ("wget -v -nv -O- --header=\"Authorization: GoogleLogin auth='${authToken}'\" --header=\"X-HTTP-Method-Override: DELETE\" --post-data=\"\" " substr($0,52,length($0)-55)) }' 2>&1 | grep gsessionid | awk '{print("Deleting " NR "\11\13"); system("wget -nv -O- --header=\47Authorization: GoogleLogin auth='${authToken}'\47 --header=\47X-HTTP-Method-Override: DELETE\47 --post-data=\47\47 \47" substr($0,index($0,"gsessionid")-97,130) "\47")}'
Hi,
I'm facing the same problem while I need to delete multiple entries at my Google Calendar. Since I'm not a developer, can you give some help on what type of batch I need this code to be run?
Thx in advance,
Miguel
Hi,
I'm having the multiple calendar entries problem, and since I'm not a developer I would like to know some details on how to run this batch.
Thx in advance,
Miguel
it is a bash script, not a batch script. it is meant to run in a Linux shell.
copy the text in my previous post to a file called delevents.sh.
change the following details to match the entries you want deleted:
guser=YourGmailUsername@gmail.com
gpass=YourGmailPassword
minTime=2008-07-18T12:29:00
maxTime=2008-07-18T12:29:59
maxResults=2
set execute permission on the file:
chmod +x delevents.sh
run the file:
/bin/sh delevents.sh
Thanks, this is great! The only problem I have is that when trying to get the bash script working I get extra %0D after the dates and maxResults: http://www.google.com/calendar/feeds/default/private/full?start-min=2008-11-03T12:29:00%0D&start-max=2008-11-10T12:29:59%0D&max-results=2%0D
This gives then "Invalid value for start-min parameter:" error.
The script works ok if I hard code the dates in the wget command.
How do I get rid of the extra %0D's?
Thanks, Martti
0D is hex for a space character, so you either have a space at the end of the lines (where you set minTime, maxTime and maxResults), or there is a space where you are inserting those variables when calling wget.
use --no-check-certificate if the first command does not return anything. (some version of cygwin might have this problem)
I guess you can use the following free web application: http://elementi.ws/gcalendarcleaner/
Post a Comment