From: Aaron H. <mai...@ha...> - 2005-05-27 22:28:06
|
Hi Greg, > However, the fact that Tiger saves calendars > as folders is causing some confusion. I don't know exactly how this > works... do we need to make the search for calendars recur to search > subfolders? in case it's of any use or interest, i wrote myself a little Perl script to make symlinks from the new Tiger calendar files to the old ~/Library/Calendars/ location, where my phpicalendar and other things still expect them to be... I've attached the script and also pasted it inline, in case attachments are stripped. cheers, Aaron #!/usr/bin/perl use warnings; use strict; # FILE: ical_links.pl # AUTHOR: (mithras.the.prophet, which is a gmail account) # PURPOSE: makes symlinks from new Tiger iCal calendars to old ~/ Library/Calendars location # HISTORY: # 04/26/2005 - initial version # ## Settings my $source_dir="$ENV{HOME}/Library/Application Support/iCal/Sources"; my $source_calendar_filename="corestorage.ics"; my $target_dir="$ENV{HOME}/Library/Calendars"; ## # # 1. scan the source directory for appropriate calendars my @calendars; # this will hold hashes of name & location opendir(SOURCE_DIR, $source_dir) or die("Can't access source calendars in '$source_dir'\n"); while (my $subdir = readdir(SOURCE_DIR)) { # only use .calendar directories that have a corestorage file if (-d "$source_dir/$subdir" && $subdir =~ m/\.calendar$/ && (-e "$source_dir/$subdir/$source_calendar_filename")) { # We have an appropriate calendar # 2. record the location my %thiscal; $thiscal{'location'} = "$source_dir/$subdir/ $source_calendar_filename"; # 3. Extract the calendar title open (CAL_INFO, "$source_dir/$subdir/Info.plist") or die("Can't get information on calendar: $source_dir/ $subdir\n"); my $title_next = 0; while (<CAL_INFO>) { if (m/<key>Title<\/key>/) { $title_next = 1; } if ($title_next && m/<string>([^<]+)<\/string>/) { $thiscal{'title'} = $1; $title_next = 0; } } close(CAL_INFO); # 4. Add this calendar to the list push(@calendars, \%thiscal); } } close( SOURCE_DIR ); # # Step 5: make symlinks # foreach my $cal_ref (@calendars) { my $newfile = $target_dir . '/' . $cal_ref->{'title'} . '.ics'; print "Linking $newfile -> " . $cal_ref->{'location'} . "\n"; symlink( $cal_ref->{'location'}, $newfile ); ; } |