We run an iCal Server at work, and the mandate has been handed down that everyone needs to be subscribed to a “Vacation Calendar” that a couple people in the building maintain (my boss, the head of Operations, and the Dean’s assistant). For the most part, this has been really easy. We just created a “Vacation” user, and subscribed people to it’s calendar on the server with iCal. However, we have a couple PC users in the building that use Outlook, and Outlook wants an ICS file to subscribe to… not a directory. It seems like iCal Server is supposed to (or at least version 1 did) give the client a combined ICS file if you just hit the directory of the user’s calendar without specifying anything else. This doesn’t appear to work though.
So, as a work around, I wrote up a very simple shell script that concatenates all the ics files for the vacation user into one ICS.
#!/bin/sh #This users caldav directory. Something like: #/Library/Calendar/calendars/__uids__/7E/1B/7E1B373E-8F22-469F-8BDF-5C3ECB996156/calendar INPUT="" TEMP="/tmp/temp.ics" #Where you want the combined ics file to go. Should be a web hosted directory if you expect to have clients subscribe to it. Something like: #OUTPUT="/Library/WebServer/Documents/vacation.ics" OUTPUT="" echo "BEGIN:VCALENDAR PRODID:-//Vacation Merge//example.com// VERSION:2.0 X-WR-CALNAME:Vacation Calendar" > $TEMP cat $INPUT/*.ics | grep -v "BEGIN:VCALENDAR" | grep -v "END:VCALENDAR" >> $TEMP echo "END:VCALENDAR" >> $TEMP tr -d '\r' < $TEMP > $OUTPUT
The big points here are, while you can just do `cat *.ics > /some/place/merged.ics` the “BEGIN:VCALENDAR” and “END:VCALENDAR” are still in there, which end up at the start and stop of each of the events in the calendar. Calendar software will stop reading once it hits one of those “END:VCALENDAR”… so the `grep -v` just removes those, and we add an end at the very end, just as we added a begin at the start.
The last line is to add unix line endings… because for some reason, this script is producing DOS line endings. *shrugs* Probably just the beginning block that has the wrong line endings. Anyway, it works.
That pretty much does it. It’s very simple. I have it run with cron every hour.
Good luck.