A script to sync an iCal/vcal calendar feed to a Google Calendar
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.




A simple Perl script to parse an iCal-format (.ics) file, and update a Google Calendar with it, via the Google Calendar API.


Why not just add the iCal feed URL to Google Calendar and let them handle it?

Because they update horribly slowly (expect about once every 24 hours).

Calendaring is a time-sensitive thing; I don't want to wait a full day for updates to take effect (by the time Google re-fetch the feed and update my calendar, it could be too late!).


The script will read your Google account details from ~/.netrc, where you should specify them as e.g.:

    machine calendar.google.com
    login yourgoogleusername
    password supersecretpassword

Of course, you'll want to ensure that file is well protected.


    ./ical-to-gcal --calendar 'Calendar Name' --ical_url ical_url

The script will fetch the iCal calendar feed, then for each event in it, add/update an event in your Google Calendar (the ID from the iCal feed is added in the extra data of the event in the Google Calendar, so the script can match them up next time).

The calendar name you provide must already exist in your Google Calendar account.

The script adds a tag to each event's content to store the UID of the event imported from the iCal feed so that events can be updated in future, or deleted if they are no longer present in the source iCal feed. If you remove this tag from an event, a new (duplicate) event will be created next time the script runs (and the old event will be "orphaned") - so don't do that.


David Precious <davidp@preshweb.co.uk>