- Exporting data out of Outlook in vcard format
- Importing PC-based vcards into Apple's Address Book
- Getting rid of duplicates in Address Book
- Exporting from Address Book to XML
- Converting from AppleScript's text encoding (MacRoman) to unicode UTF-8 (used for XML)
- Installing FOP to process XML with XSLT stylesheets and enjoying the PDF formatting possibilities
- Dealing with bugs in File Vault with AppleScript
- Easily backing up a File Vault home directory
[robg adds: This hint, with all of the included code, was over 35,000 words in length (that's about 17 pages in a typical 12-point font). I have not tested it, and since it was submitted by an anonymous user without an email address, I could not contact the author to verify my edits. So there's a reasonably good chance I made an error or two while working with the text and code for this hint -- please let me know if you find something wrong, and I'll fix it ASAP.]
- Exporting data out of outlook in vCard format:
Outlook does have a VBScript function to do so, but it is problematic. First, it misses a field I needed (other fax). Second, it is 2.0 format, and there are some fields Apple's Address Book would label unproperly (for instance, other address would become a work address). So I wrote my own VBScript [view source], tailor made for the fields I wanted to export, but very easily customisable.
This produced one long text file with all my contacts in it (c:Update.vcf). If you wanted a different vCard to export different fields or label them otherwise, here is the trick. Make a fake contact in Address Book, give information for all the fields you're interested in; export as vCard, drag this vCard to Text Edit and study the format. Then modify the above code to respect this format.
- Importing PC vCards into Address Book:
When transfered on a Mac, all the accented characters of Uptate.vcf looked funny. I didn't know yet about libconv (see below), so I just opened it with Dreamweaver (where it appeared OK), and copy / pasted to a Word document that I would then save as text only. Then a drag and drop to Address Book, which imported my 2600 contacts in seconds.
- Getting rid of duplicates:
Address Book is capable of updating a contact when you give it a vCard of a contact it already knows. But the problem with putting all your vCards in a single text document is that Address Book does not update duplicates. So I wrote an AppleScript [view source] to export them all as individual vCards into the Desktop Folder "leon." I then deleted everything in Address Book and reimported the individual vCards. Duplicates were eliminated. Be sure to check "Export Notes" in the vCard tab of the preferences of Address Book.
- Exporting from Address Book to XML:
Well, here again the AppleScript code I wrote [view source] suited the fields I used in Address Book, but you can customize it. XML export is pretty straightforward. The code will export every contact in a file called "contacts.xml" in the folder Macintosh HD -> Users -> Shared; change it as needed for your setup.
- Converting from MacRoman to Unicode UTF-8:
Place contacts.xml (from above) on the Desktop, and run this shell command on the Desktop:iconv -f "macroman" -t "UTF-8" ~/Desktop/contacts.xml > ~/Desktop/contacts2.xml - Installing FOP to process XML and stylesheets:
I know nothing about Java. So here is what I did. I downloaded FOP from xml.apache.org>, decompressed it, opened it, and moved all the files present in the folder "LIB" to /Library -> Java -> Extensions. I did not know how to set the variable JAVA_HOME permanently, so I just opened FOP.sh and wrote in it JAVA_HOME="/Library/Java/Home". Now I can process my contacts with XSLT, using an XSLT stylesheet I wrote [view source] and used, as well as an example of contacts.xml. If you install FOP, here is the command to build a very nice PDF:
Here's a sample XML contact file:/path_to_FOP/FOP/FOP.SH -xsl /path_to_stylesheet/style.xsl \ -xml ~/Desktop/contacts.xml -pdf ~/Desktop/contacts.pdf<?xml version="1.0"?> <dataroot> <Contacts> <Nom><![CDATA[NAME, Firstname]]></Nom> <Societe><![CDATA[society]]></Societe> <Telmobile1><![CDATA[mobile phone number]]></Telmobile1> <Adressebureau><![CDATA[work address]]></Adressebureau> <Telephonebureau><![CDATA[work phone]]></Telephonebureau> <Telephone2bureau><![CDATA[second work phone]]></Telephone2bureau> <Telecopiebureau><![CDATA[work fax]]></Telecopiebureau> <Adressedomicile><![CDATA[home address]]></Adressedomicile> <Telephonedomicile><![CDATA[home phone]]></Telephonedomicile> <Telephone2domicile><![CDATA[other home phone]]></Telephone2domicile> <Telecopiedomicile><![CDATA[home fax]]></Telecopiedomicile> <Adresseautre><![CDATA[other address]]></Adresseautre> <Telephoneautre><![CDATA[other phone]]></Telephoneautre> <Telecopieautre><![CDATA[other fax]]></Telecopieautre> <Adressedemessagerie><![CDATA[email address]]></Adressedemessagerie> <Notes><![CDATA[notes]]></Notes> </Contacts> </dataroot> - Dealing with bugs in File Vault:
I found AppleScript to be full of bugs when using File Vault. The solution was to never work with any file or folder that was in the protected home path (such as the Desktop). I rather used the folder /Users -> Shared/ to write contacts.xml.
- Backing up a File Vault directory:
As has been said many times, file corruption can happen using File Vault. To be able to go back in time, I have added this script to system's cron to run on a daily basis (using Cronnix to do so):
Be sure to replace SHORT_USER_NAME with the short name of the protected home directory). If anything goes wrong with File Vault, you would be able to go back in time as far as seven days ago. To do so, you would need to log out of the protected account, log in to anouther account with administrative rights, and run a command such as the following:#!/bin/bash dayofweek=`date "+%A"` destination="/Users/protected_directory_backup_$dayofweek.sparseimage" cp /Users/.SHORT_USER_NAME/SHORT_USER_NAME.sparseimage $destinationsudo mv /Users/SHORT_USER_NAME.sparseimage /Users/SHORT_USER_NAME.sparseimage.damaged sudo mv /Users/protected_directory_backup_CHOOSE_YOUR_WEEKDAY.spareseimage /Users/SHORT_USER_NAME.sparseimage sudo chown SHORT_USER_NAME:SHORT_USER_NAME /Users/SHORT_USER_NAME.sparseimage

