6 Replies Latest reply on Apr 26, 2011 8:48 AM by John Hawkinson

    [CS5 JS] DataMerge File

    Emanuele Radaelli Level 1


      Does anybody knows how to get to a dataMerge source File?

      I set the dataMerge source using a File object:


      var myFile = new File("/Users/Me/Desktop/myFile.txt");



      But then I need to get the file path and I can't see no method in dataMerge class to access to the File object.

      Am I missing something?




        • 1. Re: [CS5 JS] DataMerge File
          John Hawkinson Level 5

          What do you mean "get the file path"?


          The same path you already passed in?


          Selectign the source does not create any paths. When you run .mergeRecords() that creates a document, but does not save it. You can then choose to save the document wherever you like.

          • 2. Re: [CS5 JS] DataMerge File
            Emanuele Radaelli Level 1

            A document comes with an already set source File.

            I need to get that File path.

            That's all.

            • 3. Re: [CS5 JS] DataMerge File
              John Hawkinson Level 5

              It doesn't look like that information is exposed to scripting, so you may be stuck.


              Initially I was going to suggest you could export to IDML and parse the IDML file, but it looks like that information is not preserved in IDML. (It's not preserved in INDD either, though). Though inside the IDML file, the META_INF/metadata.xml file does contain a reference to my placed file:


                    <rdf:li rdf:parseType="Resource">
                       <stMfs:reference rdf:parseType="Resource">


              though I don't think you can rely upon that information. (it also shows up in <xmpMM:Ingredients/>).


              But while I was doing that, I noted I also had the choice to export to "adcf" (all lowercase). Which I had never seen before. I had some text of the story with the data merge markers highlighted. That gave me a small XML file:


              <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              <acf:Connection xmlns:acf="http://ns.adobe.com/AdobeConnectionFile/1.0/">
              <acf:DataSource href="file:///Users/username/Desktop/abc.txt" type="csv"/>


              But I can't seem to reproduce this export a second time! Very very strange! Too bad it would be perfect for you...

              1 person found this helpful
              • 4. Re: [CS5 JS] DataMerge File
                Emanuele Radaelli Level 1


                That looks like the only solution...



                • 5. Re: [CS5 JS] DataMerge File
                  Marijan Tompa [tomaxxi] Level 4



                  You don't have to export file to IDML to access XMP.

                  XMP can be accessed directly from JavaScript but it's little bit tricky.

                  You have to target "http://ns.adobe.com/xap/1.0/mm/" to be able to access data.


                  Hope that helps.



                  Marijan (tomaxxi)



                  • 6. Re: [CS5 JS] DataMerge File
                    John Hawkinson Level 5

                    Yeah, but I don't think the XMP metadata is very helpful.

                    At best it might include the path to this file, but not in a clear

                    way to distinguish it from other files.