Data Merge from InDesign to unique filenames – now a reality

Ever since I published the article “Breaking up is hard to do… InDesign files into individual PDFs that is!” on Colecandoo, it has been one of the most searched for and popular stories on this site.

I have also written two articles for InDesignSecrets particularly relating to Data Merge and unique filenames: Data Merging Individual Records to Separate PDFs and Data Merging Individual Records to Separate PDFs Part 2: via Scripting. While these methods work, I felt that there had to be a better way to accomplish the task.

Since returning from PEPCON 2015, I have been busy creating a javascript solution to the problem. The script is now at a stage where I am pleased with the results and would like to begin beta testing the script.

nothingselectedThe script is a user interface that is designed to work when ready to merge the records. The script:

  • Merges to uniquely named PDF or InDesign files;
  • Uses information from csv or txt in the Data Merge to create the filenames;
  • Creates web-safe filenames;
  • Provides warnings about duplicate filenames, missing images or overset text;
  • Can merge one record, a range, or all records in the database

Here are some more screenshots of the script:

resultsbadduplicatefinishedIf you are interested in trying the beta of this script, it can be downloaded from the Downloads or Scripts pages, or from the Adobe Exchange.


  1. Great script, worked well on my laptop. But for whatever reason I can’t get it to work on my desktop. I get the following error “This document has missing fonts. Please fix all missing fonts and try again.”

    But when I do Type > Find Font I do NOT have any missing fonts.

    Please advise.


  2. Love the script, but for some reason all of my exported PDFs have the correct file name according to the field I chose, but the content of all of the exported PDFs contains only data from the first record.

    • This is a feature of the PDF export directly from Data Merge – nothing to do with the script, but a part of how InDesign’s scripting DOM handles PDF export from Data Merge. It is one of the questions in the questions and answers provided in the instructions on page 15 of the instructions that are supplied with the script. It reads:

      In my PDF export options, I had the spreads radio button on, but the script has output single pages. Why?
      Just as there is a difference between PDF export options for print and interactive outputs, there is also a difference between the options for print and Data Merge, but they are far more subtle.
      The screen capture on the right hand side demonstrates the general options available when exporting to PDF via Data Merge, but note that several options are greyed out:
      The page range (not the record range)
      Create Tagged PDF
      Create Acrobat Layers
      As the options are greyed out, this means these options cannot be chosen for a Data Merge export, whether the script is used or not.

      All is not lost, but it is an added step unfortunately. That is to merge to new InDesign files first, and then use Peter Kahrel’s “batch convert” script to export the PDFs from the newly created ID files en masse.

  3. Hello,

    Perfect script!

    I have the following problem, though:

    All columns from imported CSV (Fields in database) appear in one filed. I cannot add them as separate fields to the right (Add to filename).

    Then, when trying to export, I got:

    “JavaScript Error!
    Error number: 9485
    Error String: Failed to Export the PDF file.

    Engine: main
    File: …/DM_onefileonedatabasetosinglerecordPDF_v1_26.jsxbin
    Line: 667

    I’m using recent version of InDesign CC 2017.0

    • Need to know about the origin of the csv file. Was it from excel originally, and if so, what happens if exporting as a tab delimited file and importing the tab delimited file instead of a csv?

      Is the csv file separated by commas or tabs in the csv file itself? If the file is comma separated but has a txt extension, change the extension to csv. Likewise, if the file is tab separated but has a csv extension, change the extension to csv.

      I would like to try and replicate the fault here. Can you please send me the data file (or even just the first ten lines) plus your indd file? Send it to colin (at) colecandoo (dot) com.

  4. Hello,

    Thank you very much for your help.

    Actually, I managed to export the PDFs (more than 1500, by the way, without crashes).

    The script worked when data is eported in TAB delimited TXT file, as you suggested.

  5. Great script! It worked well for me.
    However, when I tried to export PDF files that contained a form text field, the text field would not display. Is there a way to change the export function so that text fields can be included?

    • I agree, this would be a great feature. Unfortunately, the script is simply automating the naming feature of the task of Data Merge itself, and that only allows for export to InDesign or PDF for print. In fact, the PDF for print from Data Merge differs from regular PDF for print in that several options are not able to be selected. I wrote about that at the end of 2016 here:

      In the meantime, there is a workaround solution to what you would like and it is in the link posted in the previous paragraph.

  6. Thank you very much Colin. You’re article was spot on – exactly what I was trying to accomplish. The workaround was a good solution. I also took your advice and submitted my thoughts/feature request to the Adobe InDesign team.

    • I may be able to edit a script I have in development – if you have a look at the following youtube video there is a script that exports to interactive PDF instead of PDF/INDD that ID normally forces data merge to make. I can adjust it so that it would export to PNG… but I would charge for this script. Is this a solution you would be prepared to contribute a donation for?

  7. Thanks Colin!

    I’m new to InDesign and found your script and it looks like it could work great for me except that I get an error about overset text when I try to run the script. I have some chartwell fonts that require a very large font size setting to display correctly and have placeholders for the data merge to dynamically draw the chart from the csv file. This works perfectly when creating an individual merge of a single record (no overset text in the final pdf), but to use your script I have to reduce the chart font size before I can run it resulting in broken charts.

    I’ve searched for a solution to this for ages but being new I’m not even sure I’m using the right terms. I would appreciate any advice or information about a setting I can use to ignore the “fix overset text first” warning.

    • Hello there.

      The overset text warning is there to make sure that the artwork is failsafe. However you can always make the text frame auto-size by using ctrl (or command) + b to get to the text frame options of the text box and then choose the auto-size option and then make the text frame enlarge as appropriate depending on its position.

      • Thanks for your quick reply!

        I have tried this as well as trying to make the text area bigger, but this had no effect (maybe because the font size is so big?). The other issue is that some of the text is in tables and I’ve not found any articles on how to handle that.

        My current plan is to set the font size to a small value for the charts, run your script, then run another script on all 800 files to reset the font size.

        Any other ideas would be greatly appreciated.

  8. Hi Colin! I came across your script as I was searching for exactly what your script does. I want to test this out on my desktop but cannot seem to download the script as the link leads to an error where the site can’t be reached. Would you be able to send it to me?


      • I apologise for the inconvenience this is causing. I’ve tried replicating your fault on several devices and browsers here and can’t replicate the fault, but if you contact me via the contact page on this site, I can reply to you directly with a copy of the script.

      • Hello there. I’m sorry that the download is causing difficulty. I’ve added a few other locations that the script may be downloaded from at the end of the article. If issues persist, please contact me directly through my contact page on this site asking for the specific script you are having difficulty downloading.

  9. Thanks Colin for your great support … is there a way to solve how email addresses looks in the PDF filename? What I got is “name_surname_gmail_com” instead of “”. Many thanks for your precious time. Bye

  10. Im getting a scripting error now I don’t know if its just this version of InDesign or what. Im currently using 14.0.2. It was working on the previous version. Anything thoughts on how to fix it?

  11. Seems a bit slow in getting started, but it’s saved me so much hassle I don’t mind the couple of minutes of beach ball to begin with! Would be good if there were more advanced file naming options such as being able to include the name of the inDesign file and add a suffix that’s perhaps not in the database. So “Sales Report.indd” could generate “Sales Report , 2019.pdf”. Still, it only takes a few minutes in Automator in OSX to add those details. Otherwise, excellent script!! Thanks again.

  12. I wonder if it’s possible to add standard text to the filename i.e, not being filled from a database field? This would be a super useful function — we’re currently approaching this by using a renaming app.

    • Can you go into some more detail about what kind of text? Is it just static text such as an additional identical word that will be applied to each file, or is it text pulled in from a character or paragraph style? If you could elaborate, that would be great.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.