Some contacts would not export to vCard from Contacts.app, instead exhibiting the following behavior:
when clicked and dragged alone, the resulting file, "Contact.vcf", was zero KB
when clicked and dragged with unaffected contact(s), affected contact(s) would be skipped
when exported via File → Export → Export vCard..., affected contact(s) would be skipped if combined with unaffected contact(s), while no output would be produced if only affected contact(s) was/were selected.
Maurits kindly wrote in with both the cause:
[T]he affected records have in common that in ZABCDRECORD, the ZDISPLAYFLAGS column is set to NULL for the affected records. This column seems to indicate whether an entry is a company (1) or a person (0). My suspicion is that older macOS versions didn't bother to write a 0, but kept it at NULL, whereas newer versions are explicitly expecting a 0 instead of a NULL. To bolster this theory, all affected entries were rather old ones.
and actual resolution:
Close Contacts.app, fire up sqlite3 on the AddressBook-v22.abcddb file and execute
UPDATE ZABCDRECORD SET ZDISPLAYFLAGS = 0 WHERE ZDISPLAYFLAGS IS NULL;
The remainder of the post is retained for the sake of historical curiosity (and as a testament to my inextant SQL knowledge).
Tested in macOS 12.6.1 Monterey and 13.2.1 Ventura with local (i.e., "On My Mac") contacts:
Launch Automator.app
Select "Workflow" and click "Choose"
Select "Contacts" under "Library"
Drag "Get Selected Contacts Items" into the workflow area at right and leave it set to the default "Get selected people"
Drag "Export vCards" under that, select either "one vCard" or "individual vCard" from the "Export" dropdown menu, and select a destination in the "to:" dropdown menu
In Contacts.app, select desired contacts to export
In Automator, click Run
While unaffeced contacts could be deleted from Contacts.app, affected contacts could not; after exporting both affected and unaffected contacts to vCard via Automator, the contents of ~/Library/Application\ Support/AddressBook/ were deleted to clear all data from Contacts.app, then the Automator-exported vCards were imported - the previously affected contacts were no longer affected.
Apparently tools which use AddressBook-v22.abcddb like Contacts.app, abcddb2vcard, and Exporter for Contacts 2 fail on the affected contacts (despite sqlite3 queries like select * from ZABCDCONTACTINDEX;
working on those contacts from Terminal), while tools which access the associated .abcdp files instead like Automator and contact_reaper.py are able to export the affected contacts. UPDATE: relikd, the author of abcddb2vcard, has kindly updated it to handle the affected contacts in AddressBook-v22.abcddb.
Be sure to check ~/Library/Application\ Support/AddressBook/Metadata/ and ~/Library/Application\ Support/AddressBook/Sources/UUID/Metadata/ for additional contacts in .abcdp format that may not appear in Contacts.app (which is populated via the ~/Library/Application\ Support/AddressBook/AddressBook-v22.abcddb sqlite database, which is itself supposed to populate from the .abcdp files located in Metadata, though there can be orphaned .abcdp files in the latter). The only documented method for importing or converting .abcdp files is to drop the Metadata folder containing them into a blank ~/Library/Application\ Support/AddressBook/ directory under macOS Mojave or earlier and allow Contacts.app to rebuild the AddressBook-v22.abcddb sqlite database from there before exporting to vCard from Contacts.app. This process, along with Quick Look's "Add to Contacts" button for .abcdp files, stopped working as of Catalina.
However, Catalina, Big Sur, Monterey, and Ventura do work in reverse: if you copy an AddressBook-v22.abcddb into a blank ~/Library/Application\ Support/AddressBook/ directory, Contacts.app will create the Metadata subdirectory and populate it with .abcdp files (Big Sur required logging off and on for the contacts to appear in Contacts.app, and, as expected, the process did not work under Mojave).
Relatedly, if you double click an .abbu Contacts backup and select Replace All in Catalina or later, you may be left with a blank Contacts.app. Whereas if you extract AddresBook-v22.abcddb from the .abbu package and restore it to an empty ~/Library/Application\ Support/AddressBook/ directory, the contacts should appear in Contacts.app when launched.
Contacts.app's File → Export → Contacts Archive... merely makes a copy of ~/Library/Application Support/AddressBook/ with .abbu appended.
.abcdp files can be converted from Apple binary property list to XML for easier parsing (perform on copies only): plutil -convert xml1 <UUID>/ABPerson.abcdp
, though BBEdit can display either format with equal ease.
abcdp = Address Book CoreData person, abcdg = Address Book CoreData group
Find the .abcdp file which corresponds to a given contact in Contacts.app's AddressBook-v22.abcddb SQLite database:
via Terminal: grep -r -i --include=\*.abcdp foo ~/Library/Application\ Support/AddressBook/
Open Automator and create a new Quick action
Set "Workflow receives current" to "no input" and "in" to "Contacts.app"
From the Utilities group, drag the Run AppleScript action into the workflow area and paste in this script:
tell application "Contacts" set thePeople to selection repeat with aPerson in thePeople set createDate to (creation date of aPerson) set modDate to (modification date of aPerson) display dialog name of aPerson & return & id of aPerson & return & "Created: " & short date string of createDate & return & "Modified: " & short date string of modDate end repeat end tell
Save the Quick Action with a short, descriptive name
Open Contacts, select a contact (or many), and select your Quick Action name from Contacts → Services
AddressBook-v22.abcddb & SQLite
The ZABCDCONTACTINDEX table contains all contact data in the ZSTRINGFORINDEXING column (though without the associated field names):
%sqlite3 ~/Library/Application\ Support/AddressBook/AddressBook-v22.abcddb
sqlite>.output /Users/user/Desktop/contacts.txt
sqlite>select ZSTRINGFORINDEXING from ZABCDCONTACTINDEX;
sqlite>.q
Dump all tables to text: sqlite3 AddressBook-v22.abcddb .dump > ~/Desktop/all-tables.txt
parse_abcddb.rb: "Get a csv from an Apple Address Book '.abbu' archive"
How to sort contacts by creation date or modification date in iOS Contacts or OS X Contacts 7.x?
SQLite visual browsers: DBeaver, DB Browser for SQLite, SQLiteStudio, SQLite Viewer, Navicat for SQLite
SQLite data modelers/visualizers: sqleton, Luna Modeler, Navicat Data Modeler (open Navicat for SQLite and drag sqlite database file onto its Dock icon → open Navicat Data Modeler → New Model → Database: SQLite → OK → File → Import from Database... → Manage Connections → New → Import Connections to My Connections... → select Navicat for SQLite database → OK → Close → click database in Connection: dropdown menu → check top level of database → Start → Close)
SQLFluff: SQL linter and auto-formatter
Can't edit or delete mac contacts includes an answer from Linc Davis to "unlock all your user files (not system files) and reset their ownership and access-control lists to the default" via { sudo chflags -R nouchg,nouappnd ~ $TMPDIR.. ; sudo chown -R $UID:staff ~ $_ ; sudo chmod -R u+rwX ~ $_ ; chmod -R -N ~ $_ ; } 2> /dev/null
, and, failing that, to run resetpassword
in macOS Recovery.
Unable to import .abbu file into Contacts on Mac OS 15.2 reports success in Catalina 15.3 with restoring contacts from the Metadata directory
Verifying that there's no way to create a vCard from just the .abcdp files.
Unable to recover contacts from Mojave to Big Sur describes a contacts restore in Big Sur working after waiting several days(?!)
ContactsCleaner offers a workaround for local Contacts.app synchronization failure caused by "son" or "daughter" labels; see also SiliconLunch's amplification.
2005, from John Siracusa's Mac OS X 10.4 Tiger review:
The Address Book and iCal applications use monolithic data and index files to store all their data, rather than individual files for each data item (contacts, events). Address Book uses a single, large data file (AddressBook.data) and two SearchKit index files (ABPerson.skIndexInverted and ABSubscribedPerson.skIndexInverted). The situation is similar for iCal, which uses a data and index file for each calendar, rather than for each individual event.
And yet Spotlight will find and display individual contacts and calendar events. Selecting one from a Spotlight search results list will open the appropriate application and take you right to the contact or event.
There actually are individual data files for Address Book contacts in ~/Library/Caches/com.apple.AddressBook/MetaData/, and these files are indexed by Spotlight. But instead of showing up in Spotlight search results as obscurely named data files, they appear as conceptual proxies for the data they contain. Unlike other Spotlight search results, there's no file path listed for Address Book contacts.
To pull this off, the Address Book metadata importer sets a custom kMDItemDisplayName for the files that it imports, using the contact name instead of the file name. The individual data files hidden files in ~/Library/Caches/com.apple.AddressBook/MetaData/ have a ".abcdp" extension. Opening one from anywhere, not just a Spotlight search results window, will cause the Address Book application to launch and display that particular person. Pretty sneaky.
2007, from Amit Singh's Mac OS X Internals: A Systems Approach:
[U]nlike normal search results, we do not see the filename of an Address Book contact in the Spotlight result list. The same holds for Safari bookmarks and iCal events. This is because the files in question have a special metadata attribute named kMDItemDisplayName, which is set by the metadata importers to user-friendly values such as contact names and bookmark titles. You can see the filenames if you search for these entities using the mdfind command-line program.
$ mdfind 'kMDItemContentType == com.apple.addressbook.person && kMDItenDisplayName == "Amit Singh"' /Users/amit/Library/Caches/com.apple.AddressBook/Metadata/<UUID>:ABPerson.abcdp $ mdls /Users/amit/Library/Caches/com.apple.AddressBook/Metadata/<UUID>:ABPerson.abcdp ... kMDItemDisplayName = "Amit Singh" ... kMDItemKind = "Address Book Person Data" ... kMDItemTitle = "Amit Singh"
2009, from Eoghan Casey's Handbook of Digital Forensics and Investigation:
The Address Book is another application that has embraced the SQLite and plist format for much of the data manipulation. For Mac OS X 10.2 through 10.4 the Address Book data was stored in the user's Library/Application Support/Addressbook/ folder in a file named Addressbook.data. This was a proprietary file format that could be easily read only with the Address Book application itself. This changed in Mac OS X 10.5, and the Addressbook.data file may still exist, but it is leftover data no longer updated.
In Mac OS X 10.5 two structures seem to replicate that data. The AddressBook-v22.abcddb is an SQLite database that contains all the data in the Address Book. Interestingly, the same data is replicated in the Library/Application Support/Addressbook/Metadata folder, storing the same data in individual files as shown in Figure 7.10. There is an .ABCDP file for each contact as well as each group in the Address Book. These files build (or rebuild) the SQLite database upon launch of the application. The SQLite database is then used for the quick searching and the integration into the Mail and iChat application for address searching. Each .ABCDP file is just a property list and can be opened easily with Plist Editor.
/mac | Feb 19, 2023