Archive for April, 2012

“Why can’t we get a nail gun?”

April 16, 2012

A wonderful and well written blog entry:

Picture Hanging

Adding dates from a spreadsheet to google calendar

April 8, 2012

My wife has lots of “on calls” and night shifts in her job.  No idea why they don’t make the rota available in a calendar-ready format such as iCal but they don’t – it’s an Excel spreadsheet.

Normally my wife goes through manually adding all her shifts to our shared google calendar, but I thought I’d help out (if I’d thought about it I would have done this sooner).  Using the very helpful googlecl (http://code.google.com/p/googlecl/) command line interface to google services I wrote this script to take dates as they appear in the spreadsheet and enter them into the calendar:

#!/bin/bash
# Add a set of dates copy and pasted from a spreadsheet to google calendar

username="yournamehere@gmail.com"
event_name="First on call"

dates=" 07-May
08-May
09-May
10-May
22-Jun
23-Jun
24-Jun
13-Aug
14-Aug
15-Aug
16-Aug
28-Sep
29-Sep
30-Sep
"

for date in $dates
do
    # Remove the dash from the above dates to get "24 Apr" so that Google cal
    # recognises it.  Bit of hack but seems to work
    date_formatted=${date/-/ }
    cal_entry="$date_formatted $event_name"
    google --user="$username" calendar add "$cal_entry"
done