Tinderbox Forum

vCard Export Template

Did a quick search on vCard here and no results. Before I expend too much effort, figured I’d ask, has anyone developed a vCard export template from the Person prototype note? Looks like it might be easy, but I’ve been fooled before. :grinning:

I’m creating a bunch of notes of people and companies for another project, gathering the data from web sites and business cards. I’d like to be able to put it all into my Contacts app when I’m done. I know I could probably export to a csv file and do the same thing, but vCard might have some broader applicability with regard to working with individual notes later on.

It would be nice if the Preview pane could parse vCard Template format.

Likewise importing .vcf as a note.

FWIW, I opened a .vcf contact on BBEdit and it looks like Apple is using VCARD version 3. I dragged a .vcf file into my outline and got an empty note. Dropping it in a note just gave a .vcf icon, as a graphic I guess.

If it’s all been done before, and after almost 20 years, I have to think it has, can someone post a link?

I’ve done it, though I don’t know that I saved the result after the task was done. It ought to be trivial, unless you have some edge-case data.

The import manager will recognize pastes and drags of type public.vcard and import them.

1 Like

I’m not aware of a ‘template’ as such. But the ‘model’ is formatted plain text export using the vCard format as a guide. Make a template, add the necessary elements. You can leave in example values from the source. Next figure out what Tinderbox attribute populates which element value. Check if the Tinderbox exported value needs some sort of transformation and then replace the template’s element value with a ^value()^ code calling the appropriate attribute with formatting if needed. For instance: ^value($Name)^ or ^value($BirthdayDate.format("l"))^, etc.

Set the export Filename extension to ‘.vcf’ or set that after export (or whatever extension your further process expects).

See also RFC6350.

From a quick Google there doesn’t seem to necessarily a fixed template and for efficiency (not redundant data) I suspect most exported cards export only the fields populated for that record. You can do the same by wrapping each discrete element in a conditional statement, e.g.

(At a conference here so no time to build any tests)

1 Like

Interesting. I wanted to see what Apple Contacts used as a vCard, so I used the share to email extension. This created a .vcf file attachment. I opened that in a text editor and took a look at the format. I dragged that file from the email onto the outline and nothing seemed to happen. I tried it again after reading your response, and this time I got a new note with the contact’s name as the name of the note. But the only attribute was a URL for the file.

So I went to Contacts and dragged the contact itself onto the outline and it did import as you describe.

I’ll take a stab at it. I just recall Michael Becker’s recommendation to ask on the forum.

Yep, thanks. I’ll take a stab at it. I’ll let you know how it turns out! Fingers crossed. :grinning:

You’re quite right about asking here! It’s Murphy’s Law that no one has done this (or kept the results) but likely we can make a model that can be used.

The approach of taking an Apple Contacts card sounds good. I’d make a dummy contact and fill out all the fields, even if you don’t always use them. Then you’ve a meta template and can wrap all/some items (i.e. tags and values) in conditional queries, as only used tags are emitted along with any boilerplate.

If making a general model for this it might be useful to annotate any user fields needed - i.e. where the tag has no source for values from existing system attributes.

Anyway do ask if stick on any particular issues and thanks for sharing.

1 Like