Skip to content

Instantly share code, notes, and snippets.

@talkingmoose
Last active October 9, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talkingmoose/241a4e2517215ec90548 to your computer and use it in GitHub Desktop.
Save talkingmoose/241a4e2517215ec90548 to your computer and use it in GitHub Desktop.
Export contacts from all address books in Outlook for Mac to individual .vcf files
tell application "Finder"
set tmpFolder to "Outlook Address Books"
try
set tmpLocation to make new folder with properties {name:tmpFolder} at path to desktop
on error
set tmpLocation to folder tmpFolder of folder (path to desktop)
end try
end tell
tell application "Microsoft Outlook"
set theAddressBooks to every address book
end tell
repeat with anAddressBook in theAddressBooks
tell application "Microsoft Outlook"
set addressBookName to name of anAddressBook
try
set addressBookAccount to name of account of anAddressBook
on error
set addressBookAccount to "Delegated Account"
end try
tell application "Finder"
try
set addressBookFolder to make new folder with properties {name:addressBookName & " (" & addressBookAccount & ")" as string} at tmpLocation
end try
end tell
set contactsList to every contact of anAddressBook
repeat with aContact in contactsList
set contactDetails to vcard data of aContact
set contactID to id of aContact
set contactFile to contactID & ".vcf" as string
tell application "Finder"
try
set fileReference to open for access file ((addressBookFolder as string) & contactFile as string) with write permission
write contactDetails to fileReference
close access fileReference
end try
end tell
end repeat
end tell
end repeat
display dialog "Successfully exported " & (count of theAddressBooks) & " address book folders to a temporary folder on your Desktop. Open each address book folder and drag all .vcf files into your Google account contacts in Apple Contacts." with title "Export Complete" buttons {"Show Address Books"} default button {"Show Address Books"}
tell application "Finder"
activate
open tmpLocation
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment