Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Export Address Book to records to CSV format Apps
I wanted to be able to move all of the info for my Address Book contacts into my GMail account: phone numbers, addresses, etc. I tried AddressBookToCSV, which exports all Address Book entries to a CSV file which I can import in GMail, but it didn't capture everything.

So I wrote this AppleScript, which basically loops on all contacts in the Address Book and exports each of them (using a list of fields to export) into a text file. There are three lines to configure at the top of the script: where you want the result, which fields you want to export, and if you want duplicate entries for multiple email addresses -- i.e. a user with three email addresses will be exported to three different lines.

Note: You can remove fields from the default list, but you can't add any other field unless you also add a block of code to export it correctly below. Some fields are easy to export, like names or organization names, but others, like addresses or phone numbers, are trickier. Enjoy!

[robg adds: I tested this script and it worked, with one caveat: If I left the third config option (for multiple entries for multiple email addresses) set to true, then the script would unexpectedly quit before finishing. Once I changed it to false, it worked as described.]
    •    
  • Currently 3.17 / 5
  You rated: 4 / 5 (6 votes cast)
 
[51,507 views]  

Export Address Book to records to CSV format | 6 comments | Create New Account
Click here to return to the 'Export Address Book to records to CSV format' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Export Address Book to records to CSV format
Authored by: hembeck on Nov 08, '04 07:28:21PM

Shoot, I'm feeling like I got a dinosuar OS (Jaguar). This is about the 5th utility that I've come across this week, which requires 10.3.

I gave it a shot, and sure enough, it didn't work. All it exports out is name & email fields. Bummer that I can't code, since the source code is available.

-Fernando

---
--Health, Wealth and Happiness--



[ Reply to This | # ]
problem with applescript?
Authored by: dwyer on Jul 17, '07 04:36:46PM

I've never run a script before, and Was thrilled to find this applescript. But it didn't work- I turned the last option (for multiple entries) to false, as reccomended, however the script got to some part about "touch" and was looking for the csv file on the desktop. I thought it was going to create the csv file. Any help?
thanks!



[ Reply to This | # ]
problem with applescript?
Authored by: chyna4xena on Jul 19, '07 05:14:06PM

The touch command will create a file that doesn't exist, but it cannot create directories. The script as written points to a file on the desktop of a user (and hence a user folder) called "gb". This folder (/Users/gb/) is unlikely to exist on your system. You'll need to substitute your own username for "gb".

If you're unsure what your username is, just look inside the Users folder of your hard drive. The name of the folder which has the "house" icon is your username.

Re-write the "set saveCVSExport" variable at the the top of the script to point to /Users/(your user name)/Desktop/contacts.csv instead of /Users/gb/Desktop/contacts.csv and you should be right, it worked for me.



[ Reply to This | # ]
Export Address Book to records to CSV format
Authored by: hchall on Oct 11, '07 02:13:24PM

Thank you, gboudrea! This script was easy to run and executed well on 10.4.1. Actually, this was the first AppleScript I've ever executed with the Script Editor. Apple should hire you to do more of the obvious.



[ Reply to This | # ]
problems with Groups and Notes
Authored by: SaphireBlue on Dec 06, '08 11:08:54AM

this script does not export the groups that contacts are in.

more importantly, if you have notes with newlines it creates new records for each new line and subsequent fields also go into new records.



[ Reply to This | # ]
Export Address Book to records to CSV format
Authored by: paopao69 on Apr 13, '11 03:09:35PM

ran it in 10.2.8 and received various errors... first of which;
toAdd variable not defined, likewise with fieldname variable

can you tweak this script to run in the older version of OS? You would be a life saver!



[ Reply to This | # ]