7 Replies Latest reply on Sep 19, 2011 3:33 PM by [Jongware]

    Importing VCF (v-card)

    Benoît. Adobe Community Professional

      Hello everyone,

       

      Challenging question for you :

       

      Does anyone know a way to import the content of a v-card (vcf format) into InDesign ?

       

      Of course, I have tried File -> Place, Datamerge, XML.... Anything I could think of ! But no luck.

      The file is not recognised. So far, the option is to import the v-card in a program that can then export it in text to import it using data merge in InDesign.

      It's just time consuming and boring.

       

      Any suggestion ?

       

      Thanks,

       

      Ben

        • 1. Re: Importing VCF (v-card)
          [Jongware] Most Valuable Participant

          Piece of cake. Add ".txt" after the file name and you can import the raw data -- it's some sort of basic plain text file format.

           

          Would you like a script to import them?

          1 person found this helpful
          • 2. Re: Importing VCF (v-card)
            Peter Spier Most Valuable Participant (Moderator)

            Where are the v-cards stored now? If they're in an address book, perhaps you can export the whole book to .csv or tab delimited text.

            • 3. Re: Importing VCF (v-card)
              [Jongware] Most Valuable Participant

              A javascript to import the plain text in a vCard. The usual conditions apply (Save As Javascript, Run Only On VCard Files, etc.)

               

              Note that it doesn't do any data filtering *at all* -- items are inserted on the current text cursor insertion point in the order they appear inside the vCard file, and not sorted in a "Name / Address / City" ordering (unless they were already in that order).

               

              if (app.documents.length == 0 || app.selection.length == 0 || !(app.selection[0] instanceof InsertionPoint))
              {
                   alert ("PLease place the cursor where you want to insert the text");
              } else
              {
                   f = File.openDialog ("Select a vCard", function (f){return (f.name.match(/\.vcf$/i)); });
                   if (f)
                   {
                        myFile = File(f);
                        if (myFile.open("r"))
                        {
                             ln = myFile.readln();
                             if (ln == "BEGIN:VCARD")
                             {
                                  while (!myFile.eof)
                                  {
                                       ln = myFile.readln();
                                       if (ln.substr(0,8) == "VERSION:")
                                            continue;
                                       if (ln == "END:VCARD")
                                            break;
                                       if (ln == "PHOTO;BASE64:")
                                       {
                                            while (!myFile.eof)
                                            {
                                                 ln = myFile.readln();
                                                 if (ln.substr(0,2) != '  ')
                                                      break;
                                            }
                                       }
                                       
                                       if (ln.match(/^item\d+\./))
                                            ln = ln.substr(ln.indexOf('.')+1);
                                       item = ln.substr(0,ln.indexOf(':'));
                                       if (item.indexOf(';') >= 0)
                                            item = item.substr(0,item.indexOf(';'));
                                       data = ln.substr(ln.indexOf(':')+1);
                                       if (data.length)
                                            switch (item)
                                            {
                                                 case 'N':     // Name
                                                      break;
                                                 case 'FN':     // Formatted name
                                                 case 'ORG':     // Organization
                                                      list = data.split(';');
                                                      for (i=0; i<list.length; i++)
                                                           if (list[i].length)
                                                                app.selection[0].insertionPoints[-1].contents = list[i]+"\r";
                                                      break;
                                                 case 'X-ABUID':     // Some unique ID?
                                                 case 'X-ABShowAs':     // Not interesting
                                                      break;
                                                 default:
                                                 //     app.selection[0].insertionPoints[-1].contents = "["+item+"]["+data+"]\r";
                                                      if (data.length)
                                                      {
                                                           list = data.split(';');
                                                           for (i=0; i<list.length; i++)
                                                                if (list[i].length)
                                                                     app.selection[0].insertionPoints[-1].contents = list[i]+"\r";
                                                      }
                                            }
                                  }
                             } else
                                  alert ("This might not be a supported file");
                             myFile.close();
                        }
                   }
              }
               
              

              • 4. Re: Importing VCF (v-card)
                Benoît. Adobe Community Professional

                Wow !

                Very efficient the English forum ! Héhé

                 

                Thank you for the script idea and THANKS for the script.

                I have to try that right now. I will let you know.

                 

                I've already tried to change the .vcf by .txt but it's importing all the file and 90 % of it is just junk.

                 

                Thanks

                • 5. Re: Importing VCF (v-card)
                  Benoît. Adobe Community Professional

                  Thanks Peter,

                   

                  Yes, the files are store in Address Book on Mac OS Lion (maybe I should have started by this point !).

                  Actually, I just need one contact at a time (usually the last one imported) and I don't need the whole list.

                   

                  But your answer made me think and maybe I should go for something else than Address Book. I found out that Contactizer Pro can export contacts as .txt or .csv files. So, that's probably the best way to do it. Just too bad I'll have to deal with another programm.

                   

                  Thank you

                  • 6. Re: Importing VCF (v-card)
                    Benoît. Adobe Community Professional

                    Thank you for the script Jongware,

                     

                    I'm a bit ashamed to say that, but I didn't really know what to do with it and couldn't manage how to make it work.

                     

                    Maybe one day I'll find a plug-ing to import natively and simply v-cards to an InDesign document, but for the time being, I am just exporting the v-card from Contactizer Pro as a text (csv) file then use data merge in InDesign.

                    Lots of clics to do it, but it works.

                     

                    Thanks

                     

                    --------------

                     

                    Correction :

                     

                    Ok, well, I had a bright idea and manage to make the script work.

                    IT WORKS PERFECTLY.

                     

                    Great, thanks again ! It's going to be very usefull.

                     

                    Ce message a été modifié par: Benoit Pennecot

                    • 7. Re: Importing VCF (v-card)
                      [Jongware] Most Valuable Participant

                      Benoit Pennecot wrote:

                       

                      IT WORKS PERFECTLY.

                       

                      Yeah I tend to have that effect on people

                       

                      Good work gettting the script to work! Some people shy away from plain using scripts because it appears "complicated" to them, and it's always nice to hear someone doesn't give up straight away and Makes It Work.