Preserve 'my card' in Address Book after iSync over .mac

Nov 19, '03 10:14:00AM

Contributed by: Christian Leue

I use iSync and .mac to maintain the same address book and iCal calendar on my wife's Cube and my PowerBook. Unfortunately, even under Panther, the "my card" entry also gets synchronized, so my wife becomes me and vice versa, depending upon who last changed an entry in the Address Book. This becomes annoying when, for example, iChat picks up the modified "my card" entry. Fortunately, the new Address Book in Panther lets you manipulate "my card" via AppleScript. So, it was a piece of cake to write the following scriptlet which restores "my card" after performing a sync.


try
  -- pick up current "my card"
  tell application "Address Book" to set CurrentMyCard to my card
    
  -- invoke a sync
  tell application "iSync" to synchronize
 
  -- wait for sync to finish
  repeat
    tell application "iSync"
      if (syncing is false) then
        exit repeat
        do shell script "sleep 15"
      end if
    end tell
  end repeat
  
  -- tell 'em who's the boss if iSync changed it 
  tell application "Address Book"
    set NewCurrentMyCard to my card
    if NewCurrentMyCard is not CurrentMyCard then
      set my card to CurrentMyCard
      save addressbook
    end if 
  end tell
end try
PS: I seem to recall that it used to be difficult to run AppleScripts from the crontab. I don't know if it is new in Panther, but I used the "save as a program" option in Script Editor 2.0, and placed a reference to it directly in my crontab for execution at 10 minutes to the hour:
50 * * * * /Users/myaccount/Scripts/sync_restore_my_card.app
And it worked as expected...

Comments (17)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2003111210362559