1 Reply Latest reply on Apr 8, 2009 8:48 AM by Kasyan Servetsky

    Scripting a file name change as a data merge element.

      My goal of the work being done with InDesign is to utilize the Data Merge functionality of InDesign and the, already available, ability to create a new document per record in your data source where the docuement name is changed based on data contained in the data source.
      A very simple example of this would be the following:
      EXAMPLE
      ======================
      Given the following data source in excel:
      First_Name
      Last_Name
      ResultingFileName
      George
      Smith
      c:\A45.pdf
      Mary
      Lopez
      c:\C99.pdf
      Steve
      Barns
      c:\tmp\XM96TR.pdf
      Along with a simple two text box InDesign documents, I would perform a standard data merge with First_Name linked to one text box and Last_Name linked to another.  By setting the “Record Limits Per Document” to 1, I would end up with three different documents.  By default, the documents would be named Untiltled-1, Untiltled-2 and Untitled-3. 
      Untitled-1 would contain George and Smith.  Untitled-2 would contain Mary and Lopez and Untitled-3 would contain Steve and Barns.
      At this point in time, I would run the new created script, which would do the following:
                  Rename Untitled-1 to A45 and/or save Untitled-1 as C:\A45.pdf
                  Rename Untitled-2 to C99 and/or save Untitled-2 as C:\C99.pdf
                  Rename Untitled-3 to XM96TR and/or save Untitled-3 as c:\tmp\XM96TR.pdf
      I am open to modifying the manner in which the data merge source is created.  For example, separating the path and the file name into separate columns.  In addition, I am flexible in putting preset information and/or file save types into the data merge document.
      Please feel free to contact me directly at mlehrer@teamworkathletic.com
      Thanks in advance for the help.
      Matt
        • 1. Re: Scripting a file name change as a data merge element.
          Kasyan Servetsky Level 5

          Hi Matt,

           

          I think it’s better to use an XML-based approach for your task.

          I’ve never scripted Data Merge process, but I don’t see a straightforward way of doing it. May be you can create the 3rd textbox on pasteboard or a non-printing layer, which will contain the file path from ‘ResultingFileName’ field, and the contents from which can be used for naming & saving the current file and exporting it to pdf-file. But this approach is so clumsy.

           

          Instead, you’d better to keep your data in excel file, or even better Access or some other database program.

          Export the data from it in XML-format.

          Then import it to an InDesign file and process it by script. XML support is very powerful in InDesign: you can process your data by xml-rules. I once made a script for a newspaper, which processed data for classified ads. The script applied all formatting, changed colors for different headings and placed images.

           

          Kasyan