Skip to Content

AppleScript: backup iCal calendars

iCal is great for storing your calendars and appointments, but what if you want to export (or backup) your calendars in case of a data emergency? Well, you could backup your calendars manually; however, AppleScript is so much cooler. Let's automate the backup of iCal calendars through the use of an AppleScript.

Continue reading to learn how.


Exporting iCal calendars

To export iCal calendars, just copy this script into Script Editor.app (Applications > AppleScript > Script Editor).

tell application "iCal" to activate
delay 2
tell application "System Events"
tell menu item "Export..." of menu "File" of menu bar 1 of application process "iCal" to click
delay 3
keystroke "iCal"
keystroke "d" using command down
delay 2
keystroke return
end tell


Please note: this script assumes that you are using Mac OS X Leopard (version 10.5) and iCal version 3.0.

Running the Script
Once you have that AppleScript in the Script Editor, let's hit the "Run" button. iCal will launch and will show a save dialog, the script will then type in "iCal" and press the "save" button. Your exported .ics file will be located on your users desktop.

Saving the Script
You can then save the script as your favorite format flavor. I prefer to either put it in the Script menu or save it as an application.

Uses of this Script
Once you have the .ics file, you can use the file to import to Microsoft Entourage or Google Calendar; or you can just use it as an iCal backup file.

Additional Notes
  • Remember that iCal will only backup the currently selected calendars
  • In order to use scripts such as these, you need to check "Enable access for assistive devices" in the "Universal Access" System Preferences pane
  • While the script is running, be sure to not press any keys on the keyboard


Categories

Features How-tos

iCal is great for storing your calendars and appointments, but what if you want to export (or backup) your calendars in case of a data...
 

Add a Comment

*0 / 3000 Character Maximum

7 Comments

Filter by:
Poon Tangy

How about an automator script that backs up my iTunes Smart Playlists! ;-)

March 30 2008 at 3:33 PM Report abuse rate up rate down Reply
Ken

I use an Automator workflow to backup the entire iCal data folder:
HD>Users>myUsername>Library>Application Support>iCal

This way iCal doesn't have to be open.


March 30 2008 at 3:08 PM Report abuse rate up rate down Reply
1 reply to Ken's comment
newsray

If you have a freshly installed iCal under Leopard, iCal stores its data in ~/Library/Calendars.

If you are using Leopard and Time Machine, both of these directories are automatically backed up.

March 30 2008 at 3:14 PM Report abuse rate up rate down Reply
Michael Rose

Ham, see the additional notes at the bottom of the post. Most likely you need to turn on access for assistive devices.

March 30 2008 at 2:44 PM Report abuse rate up rate down Reply
a ham sandwich

ham

u need to replace export with "Back up iCal...". should work if u have leopard.
btw WTF DID U STEAL MY NAME?

March 30 2008 at 2:41 PM Report abuse rate up rate down Reply
hamsammich

I get the following error on run:

System Events got an error: Can't get menu item "Export..." of menu "File" of menu bar 1 of application process "iCal".

I'm not much of an Applescripter, but this one had quite a bit of potential for me.

March 30 2008 at 2:24 PM Report abuse rate up rate down Reply
1 reply to hamsammich's comment
CajunLuke

For the "Export…" string, did you use an ellipsis (…) or did you use three periods(...). You need to use an ellipsis - press Option-; to get one.

March 30 2008 at 2:44 PM Report abuse rate up rate down Reply
Buy an ad here

Hot Apps on TUAW

Tweets

© 2012 AOL Inc. All Rights Reserved.