This is a Python script to export contacts from the macOS Contacts app in vCard format to Markdown files with structured data. The script is compatible with Python 3.
Clone this repository or download the script file main.py.
This script requires the vobject and dateutil Python packages. To install them, run:
pip3 install vobject python-dateutil
- Open the Contacts app on your macOS.
- Create or select a contact group that you want to export.
- Open a terminal window and navigate to the directory where you saved
main.py. - Run the script with
python3 main.py.
By default, the script exports the contacts from a default "Obsidian" group and saves the Markdown files in the "π Contacts" folder. You can customize these settings by setting the CONTACT_GROUP and OUTPUT_FOLDER environment variables, respectively.
The script exports each contact as a Markdown file with the following structure:
## π€ Name
- π§ Email: [[email protected]](mailto:[email protected])
- βοΈ Phone: [+1 (555) 123-4567](tel:+15551234567)
- π Birthday: [[20000101]]
- π Anniversary: [[20100101]]
- π’ Organization: Example Inc.
- π Note: Some notes about the contact.
- π Website: [example.com](http://example.com)
- π Location: 37.7749Β° N, 122.4194Β° W
- πΌ Role: Some role
- π Title: Some title
- βοΈ Gender: F
- π£οΈ Language: English
- π Address: 123 Main St, Suite 100, San FranciscoThe script supports the following vCard fields:
fnemailtelbdayx_anniversaryorgnoteurlgeoroletitlex_genderlangadr
If a vCard field is not present in a contact, the corresponding section will not be included in the Markdown file.
The script replaces any illegal characters (\, /, *, ?, :, ", <, >, |) in the contact name with underscores (_) to avoid issues with file naming.