Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Sync iCal 2.0 Calendars via SSH Apps
Tiger only hintI am not lucky enough to have a server with WebDAV, so in the past, I have used scp to copy the iCal calendar files to my server for use with phpical.

I recently found out (as of 10.4) that the calendar files are no longer accesible in ~/Library/Calendars. They are actually stored in ~/Library/Application Support/iCal/Sources/coredata.ics. This not only makes it hard to upload them because they are in seperate folders, but they also have the same name. So I wrote a Python script (this code is also available at to get the 'real name' of the calendar file out of a plist and upload the calendar with that name.

I use ssh keys to do this; google is required to figure that portion out.
  • Currently 3.20 / 5
  You rated: 3 / 5 (5 votes cast)

10.4: Sync iCal 2.0 Calendars via SSH | 9 comments | Create New Account
Click here to return to the '10.4: Sync iCal 2.0 Calendars via SSH' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Sync iCal 2.0 Calendars via SSH
Authored by: cheesy9999 on Jun 21, '05 12:49:57PM

Google...or man pages...whatever happened to good ol' man page hunting?

[ Reply to This | # ]
10.4: Sync iCal 2.0 Calendars via SSH
Authored by: seancorfield on Jun 21, '05 11:06:43PM

If you have a Mac, you have a WebDAV ready server.

My approach to the iCal problem was to enable WebDAV on Apache on my PowerBook and have iCal publish all changes automatically to localhost. Then my old "" ftp script just picked up the .ics files from the new location instead...

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

[ Reply to This | # ]
10.4: Sync iCal 2.0 Calendars via SSH
Authored by: iamdw on Jun 21, '05 11:16:18PM
"have iCal publish all changes automatically"

what do you mean by this, and how is it done? i looked in all the iCal prefs/menus and found nothing to auto export?

[ Reply to This | # ]
10.4: Sync iCal 2.0 Calendars via SSH
Authored by: mannkind on Jun 22, '05 03:53:36AM

(Author of the script, didn't register before submitting the hint)

Essentially you are using webdav and a script (in bash, ruby, perl, whatever) to do the job that this python script does all on it's own.
It doesn't make much sense to use webdav and a script unless you have webdav turn on for other things as well. Even then, using webdav does not produce more accurate results on the server because the ftp upload script is still a cron job.

Why have a webdav service that effectively isn't doing anything but renaming the files for you? It seems pointless.

Anyways, I hope a few people enjoy the script. I know I do. Although the bash script to upload was more simple, the python script does the job.


[ Reply to This | # ]
10.4: Sync iCal 2.0 Calendars via SSH
Authored by: iamdw on Jun 21, '05 11:13:03PM
great script whomever you are that wrote it... i was getting worried that i would not be able to get my phpicalendar updated anymore with the new data structure and phpicalendar no longer being updated (what the hell happened? ...willingly offline? ah well)

thank you much!

[ Reply to This | # ]
10.4: Sync iCal 2.0 Calendars via SSH
Authored by: clp698 on Jun 21, '05 11:44:30PM

I too was taken by the new calendar format. But then I did an export of the calendar into an .ics file from the file menu and uploaded that file into phpicalendar and it worked just fine.

[ Reply to This | # ]
10.4: Sync iCal 2.0 Calendars via SSH
Authored by: iamdw on Jun 22, '05 05:00:31PM

it's true you can export from within iCal itself. The problem is automating it... this is why the pythin script is so handy. I looked into using Automator, but was unable to find a way to export at all, nevermind periodically. You could probably set up an applescript GUI events or whatever they are called, but i was too lazy to learn how to do that again. It's also a bit clunky to run that kind of applescript anywhen..

[ Reply to This | # ]
Script to copy iCal2 calendars to the old iCal locations
Authored by: dhirsch226 on Jun 22, '05 11:57:41AM

(I submitted this as a hint, but the python script hint was ahead of mine. These do not do exactly the same thing. My script will copy the iCal2 .ics files to ~/Library/Calendars on the same machine, optionally omitting calendars to which you've subscribed. It doesn't upload anything. It will erase anything in ~/Library/Calendars first, so by putting this script in a cron job, you can keep a set of perfect duplicates in the old location. Here's my hint:)

I had created some scripts to copy my .ics files from ~/Library/Calendars to a spot where PHP iCalendar could serve them up.

With Tiger and iCal2's hierarchical calendars, this broke and was not easily fixed. The calendar files now live in ~/Library/Application Support/iCal/[inscrutable folder name here]/Sources/corestorage.ics. Ugh. Anyway, I made a script to copy figure out the names of the calendars from the associates Info.plist files, and copy them to the old location with the correct names. There is a setting to optionally omit subscribed calendars from being copied.

Note that this script will delete anything currently in ~/Library/Calendars (so you can put it in a cron job, and keep the calendars updated). You will also, of course, lose your iCal2 hierarchies. Here's the script. I named it iCalCopier.command, so that I can double-click it if needed. You will also want to chmod +x it to make it executable.


# iCalCopier 1.2
# by Dave Hirsch, 6/5/05
# This script will copy each iCal2 .ics file into the old iCal location, so that
# other scripts which expect to find the calendar files there will work.
# It also renames the files to reflect the calendar names.  Note that it does not preserve the
# iCal2 hierarchies!  Also note that it will delete the contents of ~/Library/Calendars when it
# first runs.
# To use this script, put it someplace you can get to, then make it executable 
# (chmod +x iCalCopier2.command)

# The script optionally omits copying of subscribed calendars.  Change the following line to
# determine this behavior

ICAL2DIRECTORY="/Users/$myUserName/Library/Application Support/iCal/Sources"

# Create the destination directory if it doesn't exist
if [ ! -d "$ICAL1DIRECTORY" ]              # Test whether calendar directory exists,
  mkdir $ICAL1DIRECTORY                           # and make it if it doesn't exist
  rm -f $ICAL1DIRECTORY/* > /dev/null             #  If it does exist, clean it out quietly.

        if [ -d "$ICAL2DIRECTORY/$CALDIR" ]     # If the item is a directory (exclude .DS_Store files)

              # This next line does the heavy lifting of getting the Calendar title out of the
              # Info.plist file.  It looks for a line containing the text "Title", then
             # sets the AWK field separators to be both "", and then prints out field
              # 3 from the following line.
          Title=`cat "$CALFILE" | awk '/Title/ { FS = "[]"; getline; print $3 }'`

              # Check the type field to see if the current calendar is one that comes from
          # a subscription
              TypeStr=`cat "$CALFILE" | awk '/Type/ { FS = "[]"; getline; print $3 }'`
            if [ "$TypeStr" == "" ]

              if !($omitSubscribed && $Subscribed)
                  # If the calendar is not a subscribed calendar or if we don't care
                   # whether it's subscribed or not
                     cp "$ICAL2DIRECTORY/$CALDIR/corestorage.ics" "$ICAL1DIRECTORY/$Title.ics"


[ Reply to This | # ]
Script to copy iCal2 calendars to the old iCal locations
Authored by: dhirsch226 on Jun 22, '05 12:03:32PM

Also, if you're running phpiCalendar on your own server, you might choose to change the value of the ICAL2DIRECTORY variable to the server directory you want phpiCalendar to find the calendar files in.

[ Reply to This | # ]