Creating a Batch of PDFs With a Script

Outputting a PDF from a well-created InDesign file is quite painless. Outputting many PDFs from many well-created InDesign files is painless too, but it can take up a lot of your time.

Thankfully, there is a script that makes an otherwise tedious task only take a moment – Batch convert from Peter Kahrel.

batch1

In this article, the focus will be on producing PDFs from InDesign files, but Peter’s script does a lot more than that. It can also output IDML, EPS, PNG, RTF, XML, JPG, and packaged files from InDesign, INX/IDML, as well as old QuarkXPress, and PageMaker files.

20140805-batch1

Peter’s site does a great job of explaining how the script works, but there are some things that are worth mentioning before diving in feet-first to use the script.

First, I can’t stress the term “well-created” often enough. If you don’t have a Document fonts folder in the same directory as the InDesign file,  it is possible to create PDFs with incorrect fonts. Justin Putney of Ajar Productions has a script that will package just the fonts used in your InDesign documents, relieving you of having to package a file just to make a Document fonts folder.

Likewise, if links have been moved, edited, or are missing, this can again result in incorrect PDFs.

Also, as Peter mentions, there is an option in the script’s dialog box called “View PDFs after exporting”. I would highly recommend deselecting this option, unless you want Adobe Acrobat to open dozens (or possibly hundreds) of PDF files as they are created.

Changing Layer Visibility With a Second Script

There is also a checkbox that allows you to run a script on each file prior to output. This can be very handy if your files require a final touch-up prior to outputting the PDFs.

batch2

For example, you might have a set of files containing a layer that has to be hidden prior to making PDFs. An additional script could be created and used with the Batch convert script to hide the layer. Using a text editor like Notepad, TextEdit, or TextWrangler, copy and paste in the following text:

//DESCRIPTION:single serving script to hide a layer called "Position"
app.activeDocument.layers.item("Position").visible = false;

Change both instances of the layer name from Position to the name of the layer you want to hide.

Then save the file as makelayerhidden.jsx

Now, run the Batch convert script, and in the dialog box, select the option to run an additional script, and choose your newly created makelayerhidden.jsx.

batch3

Note that this will produce PDFs with the desired layer hidden, but unless you also select the option to Save changed documents on closing, the next time you open your INDD files, the layer will again be visible.

Mapping Spot Colors With a Second Script

Another reason why you might want to use a second script is to map a customer’s spot color to a known Pantone color. In the example below, the customer’s spot color is “FIRE ENGINE RED,” but the spot color it has to match is Pantone 485, and that is not currently in the InDesign files. The script is:

//DESCRIPTION:Map color FIRE ENGINE RED to PANTONE 485 C if it isn't there app.activeDocument.importAdobeSwatchbookSpotColor ("PANTONE 485 C"); myInk = app.activeDocument.inks.item("FIRE ENGINE RED"); myInk.aliasInkName ="PANTONE 485 C";

These are only two simple examples. The Batch convert script’s ability to run another script before output can save hours of production time.

It is worth noting that this is not the only script that can run other scripts.  Here are a few that I’ve found useful.

  • For those wanting to apply many scripts to many InDesign files, Kasyan Servetsky has a script that will do just that.
  • Loic Aigon has a user interface that allows a similar batch process script to be performed on one file.
  • Rorohiko has its own version of an “InDesign Action Palette” called Action recorder. At the time of writing it is still in the Beta phase.

And finally, while you can download the Batch convert script for free, consider using the Make a Donation button on Peter’s site if you use the script and find it worthwhile. Support great scripters and their work!

Bookmark
Please login to bookmark Close

This article was last modified on August 2, 2022

Comments (80)

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Patrick Flowers
    March 21, 2023

    I use this in multiple ways, and it has saved tons of time! Batch exporting 10-15 files for a proofreader used to take lots of time opening each file, updating any links, and waiting to export. Now I can *insert Ron Popiel here* Set it and forget it!

    However, I’ve run into a weird issue on this, which hasn’t happened before 6-8 months ago –
    Whenever I run the processor for Source INDD to Target INDD (used whenever CC updates to a new year, for example, or I need to update older files to be usable for new designers who might not have specific versions), it causes the INDD to disappear for some users.
    I can see it just fine, the permissions aren’t any different, but I have to run the batch processor again and they end up seeing the file eventually. It’s not every file or every directory, just on occasion after running through the processor. Any thoughts?

  2. December 11, 2018

    Hi
    ……………………
    the document page size exceeds the page size range supported in pdf files. exported pages will be resized to fit within pdf limits.
    ……………………
    I have this massage, what should I do, how to fix ti?
    please show me the solution.

    1. Peter Kahrel
      December 11, 2018

      I’ve never seen that error. It suggests that your InDesign files have large page sizes, larger than is allowed in PDFs. Reduce the page sizes in InDesign or accept that the pages are resized during PDF-export.
      P.

  3. May 2, 2018

    Hi there ;-)

    This script is absolutely genius!!! I have a special situation though:
    I have ONE InDesign-Document containing FIVE layers (German, French, Italian, Spanisch and English). What would be cool is to have the script perform following task: Open .indd-File with only German layer active, save PDF, close without saving, open the same .indd-File again, hide German layer, activate French layer, save PDF, close without saving, open .indd-File again, hide German layer, activate Italian layer, save PDF…. etc

    Would that be possible? Or would I need a special seperate script?

    Thanks for any ideas and have a nice day!

    Cheers,
    Steven R.

    1. Peter Kahrel
      May 6, 2018

      That’s fairly simple, but it’s a different script.

      1. May 6, 2018

        Thanks for sharing your knowledge

  4. Jaz
    March 20, 2018

    Since I got my InDesign updated to 13.1 the script isn’t working anymore. Any idea how I can change that?

    1. March 20, 2018

      There is an update as of 17 March 2018. Works on my Mac OSX 10.12.6 running IDCC 13.1

      1. Colin Flashman
        March 21, 2018

        Link location: https://www.kahrel.plus.com/indesign/batch_convert.html (look for the phrase 17 Mar. 2018)

      2. Jaz
        March 21, 2018

        Can you send me a link where I find the updated version?

  5. Peter Kahrel
    August 23, 2017

    That would mean some serious surgery on the script, so in effect, I’m afraid that it’s not possible.

    1. Masood Ahmad
      April 24, 2018

      Hi Peter, I have another task for you and I posted it in another post.

      I want your script to make individual packages, with an option to create Print and Web pdf using respective pdf presets.

    2. Masood Ahmad
      August 23, 2017

      I too have the same thoughts :) Meanwhile I’m okay with the current version.

  6. Masood Ahmad
    August 23, 2017

    @peter, your script works very well and I use it more often, when I have to export a number of PDFs. Is it possible somehow to batch convert both IDML and PDF in one go. Currently I export PDFs and then IDMLs.

    1. November 4, 2017

      Yes, you can do this if you batch convert ID files to ID files, and then run a script that will export to the myriad formats that you require. That part of the code you need to write/have written, but it can be executed from Peter’s script by using the “run a script” checkbox in the UI of the script.

  7. Stefanie Hausner
    July 14, 2017

    I’m loving this script and it’s helping SO much with productivity. Similarly, I’m looking for a script that would save a single PDF from InDesign to multiple locations. Our production has several distribution points, and it would help with consistency and save time. Does anyone know of one that may exist like that?

  8. Eva
    May 29, 2017

    Hi,

    the script is amazing, I just spotted one problem when I try to convert idml to PDF or Indd files, it appears a message of “object is invalid (296)”. Any idea of what could happen?

    1. Peter Kahrel
      June 2, 2017

      Eva — The script works fine here converting idml to indd and pdf. First thing to try is to delete the config file, batch_convert.txt, which lives in the same folder as the script. If that doesn’t help, please post a screenshot of the script’s interface with the settings that you use.

      P.

      1. Adil
        June 25, 2017

        Hi, first of all thank you for the script. Now I am using this script to convert p65 (pagemaker doc) to pdf but I have been receiving the same error as Eva. Additionally I am also getting the error “Problem closing ” I tried this for p65, p7 and pmd files but I got the same result. I also do not have any config file or batch_convert.txt in the script folder. Please note that when I ran this script for the first time, it successfully converted 1 of 6 pmd files to pdf.

  9. Abhijeet
    April 25, 2017

    please modify the script so that package should be created at same path where .indd is placed

  10. Brett Cox
    January 26, 2017

    Hey Colin

    Thanks for the script – just an issue with the layers script. It is hiding the layer I’ve stated – I get an error at the end “Syntax error (at line 103)”.

    Any ideas?

    1. Brett Cox
      January 26, 2017

      Sorry – it isn’t hiding the layer.

  11. Suzanne Ammon
    January 17, 2017

    I installed the batch convert script, It worked fine the first time, but now when I open the script and locate indesign documents they are shaded grey, so I can’t click on them.

    I also tried to install the scripts on the other macs in my office and, it is doing the same thing thinking maybe can’t install on more than 1 system in the office. Please help me solve this problem, I have to pdf alot of documents on a weekly basis and this would be a god send

    1. Peter Kahrel
      January 18, 2017

      (I received your reply — with screenshot — via David Blatner. If you send your reply via email, it doesn’t make it to the forum and no-one will see it apart from DB.)

      Never seen that problem before. Exit InDesign. If it asks if you want to save one or more documents even if you can’t see any, say ‘No’. Then start InDesign again and run the script again.

    2. Peter Kahrel
      January 18, 2017

      What do you mean when you say “locate indesign documents they are shaded grey, so I can’t click on them.” If script’s input field is greyed out you have some documents open. Close them and try again. Other possibility: delete the batch_convert.txt file that’s in the Scripts panel. If that’s still not it, please post a screen shot that shows what you mean.

      As to “maybe can’t install on more than 1 system”, no, it’s a script, you can install it as many times as you like.

  12. Erik
    November 30, 2016

    Now I got the script running and the thing I want to do works if I open all the documents and does the thing. Not possible to choose input folder thou and make it that way. MANY THANX FOR A WONDERFUL SCRIPT!!!!!!

    1. Peter Kahrel
      November 30, 2016

      If you can’t choose the input folder (if that field is disabled) then there is a document open (could be, even if you don’t see it). Close InDesign and restart it. Also, if there’s a text file batch_convert.txt in your Scripts folder, delete that and run the script again.

  13. Erik
    November 30, 2016

    Hi, the script does not work on my InDesign CC 2017. Is it compatible with this version??

    1. Peter Kahrel
      November 30, 2016

      Yes, it is compatible with CC2017.
      In what way does it not work? Do you see any error messages? What are you trying to do?

      P.

      1. Erik
        November 30, 2016

        I want to export PDFs from 40 different InDesign files. But when I run batch_convert.jsxbin the message pops up…

      2. Erik
        November 30, 2016

        Thanx for your answer! When I’m trying to double click/run the script it says “undefined is not an object (line 848)

  14. joseph
    October 3, 2016

    Firstly, thank you for this script! It’s increased my productivity significantly!

    My Javascript knowledge is very basic so maybe someone can help me out. I wanted to run a secondary script that converts/maps the default blacks to rich blacks for production. This would apply to text and background colours.

    Does anyone have a script for that?

    Thanks again!

  15. October 1, 2016

    i have a batch of indd book files,
    is there a way to select indb files to convert batch?

    1. Peter Kahrel
      October 1, 2016

      No, there isn’t. Convert the indd files, open the book, and all should be fine.

      Peter

      1. elena
        October 1, 2016

        ok, thanks but this cannot solve my issue since i need to covert indb books to pdfs

  16. Darius Detwiler
    August 13, 2016

    Sorry, it does not work. The Input Folder entry will not activate and allow to enter folder information. Only the Output Folder works, so I can only convert one document at a time, not as a batch. Tried several times to download and reload the script: the results are the same. Using CC 2015.

    1. Peter Kahrel
      August 14, 2016

      The input field is disabled when you have one or more documents open. Therefore close all documents, then run the script. Now you can enter a folder.

  17. Marcus
    July 29, 2016

    You’re a star. A shining one!

  18. Peter Kahrel
    April 27, 2016

    David — Did you unzip the file download? You should copy the .jsxbin file to the Scripts folder, not the zip file. Other than that I can’t tell you much. If there’s not even an error message there’s not much to go on.

    1. David
      April 27, 2016

      I did unzip the file and copied the file over to the Users script folder. The zip file that I downloaded did not have the batch_convert.txt file, which I’m assuming is okay since the troubleshooting section mentions to remove it. I will continue trying. Hopefully, it will either work or I will get an error message that I can report.

  19. David
    April 26, 2016

    I’m having trouble loading the script. I placed the file in the user folder and it appears in the script panel but when I double click the script, or select Run from the fly-out menu, nothing happens. I believe that I am doing everything correctly – not having any documents opened when I try to run the script and I’ve also tried the script with files open.

    If it helps, I am trying to use the script on a work computer using Indesign CC 2015.

    1. April 26, 2016

      I’ve noticed when using InDesign CC with the El Capitan system, that when a script is running and a progress bar would usually appear, the progress bars now seem to disappear.

      In relation to your issue, I’m not sure, but you would need to ask the author of the script.

      1. Peter Kahrel
        April 27, 2016

        Hi Colin — InDesign’s Scripts panel menu has an option ‘Enable Redraw’. Is that option checked? If not, please check it and see what happens.

  20. Chrystina Hanna
    March 16, 2016

    This is a fantastic script, saving me hours!!! But I’m having the same issue as someone above me posted: Upon exporting, I need the names of the pdf’s to be xx-OKC and don’t see how to change this. Thanks so much for the script and any advice!!!

  21. February 4, 2016

    Thanks Peter! Removing the .txt file worked a treat. Honestly this is the best script ever! If you update it in the future I’d happily pay for anything new that you create! Nic :D

  22. Gauthier
    January 11, 2016

    Hi,

    I’m on Indesign cc 2015 (december 2015) and I have the same error :
    In the begin, the script work, and after 2 ou 3 export, the script did not work :
    “undefined is not an object (line 721)”

    The script is great, it will be good to have a solution !

    Thanks

    1. Peter Kahrel
      January 11, 2016

      The script clearly needs a fix, and I’ll do that soon. In the meantime you should be able to fix this by deleting the script’s configuration file. It’s called batch_convert.txt and lives in the same folder as the script. You can see the txt file in InDesign’s Scripts panel, greyed out (if you can’t see it, select ‘Display unsupported files’ in the Script panel’s menu). Right-click the txt file and select ‘Delete script file’, then run the script again.

    2. January 11, 2016

      I think the best thing to do is get in touch with the author of the script, Peter Kahrel, and let him know what is going on. Go to https://www.kahrel.plus.com/info.html and click the “contact me here” link.

      Make sure to provide the following information:

      1) The version of InDesign you are using (as well as your operating system AND language version of InDesign you are using;
      2) The steps that were taken in order for this error to occur.

      1. Gauthier
        January 11, 2016

        Thank you Colin for your answer. Peter gave me the solution by mail, and he post this under this post.

        Thanks to the community !

      2. Peter Kahrel
        January 11, 2016

        Thanks, Colin, and thanks too for the post on this script, much appreciated.
        Peter

  23. Joseph Blunden
    November 25, 2015

    I am now getting an error any time I try to use it:
    “undefined is not an object (line 721)”

  24. luiz
    November 20, 2015

    Hi

    I need some help with parameters for two paths and one pdf in each folder. Eg like this:

    INDD FILE to
    PDF _High (path/ folder 1 /PRESS)
    PDF _low (path/ folder 2 /REWIEW)

    Of course, the destination folders are already well in place.

    This script need to be edited to this end. Is possible?

    d = app.activeDocument;
    preset1 = app.pdfExportPresets.itemByName(“[Smallest File Size]”);
    preset2 = app.pdfExportPresets.itemByName(“[Press Quality]”);
    if (!(preset1.isValid && preset2.isValid)){
    alert(“One of the presets does not exist. Please check spelling carefully.”);
    exit();
    }

    mDocName = d.name.substr (0, d.name.lastIndexOf(‘.’));
    mSourcePath = d.fullName.parent.toString();
    mRootPath =mSourcePath.substr (0, mSourcePath.lastIndexOf(‘/’));
    mTargetPath=mRootPath.concat(‘/final/’);

    mNamePrint = mTargetPath.concat(mDocName,’.pdf’);
    mNameWeb= mTargetPath.concat(mDocName,’_baixa.pdf’);

    if (!d.saved){
    d.save;
    }

    d.exportFile(ExportFormat.PDF_TYPE, new File(mNamePrint), false, preset1);
    d.exportFile(ExportFormat.PDF_TYPE, new File(mNameWeb), false, preset2);

  25. Brett
    October 26, 2015

    My documents have slug info on the pastes board with dimensions, if I use the batch convert it converts all my units from inches to mm, if I export individually through InDesign everything stays inches, as it should be. Is there anyway to specify units?

  26. October 22, 2015

    Yes. You need to make a javascript much like the one-line javascripts shown here and it needs to contain the following code:

    var myPDFprint = app.pdfExportPresets.item(“YOUR PRINT EXPORT PDF PRESET HERE”);
    var myPDFweb = app.pdfExportPresets.item(“YOUR WEB EXPORT PDF PRESET HERE”);
    app.pdfExportPreferences.viewPDF = false;
    app.activeDocument.exportFile(ExportFormat.pdfType, File(app.activeDocument.filePath + “/” + app.activeDocument.name.split(“.indd”)[0] + “_print.pdf”), false, myPDFprint);
    app.activeDocument.exportFile(ExportFormat.pdfType, File(app.activeDocument.filePath + “/” + app.activeDocument.name.split(“.indd”)[0] + “_web.pdf”), false, myPDFweb);

    So swap out the YOUR PRINT EXPORT PDF PRESET HERE for the name of your print PDF preset EXACTLY as it appears in InDesign. Same thing with the web preset line – swap out the YOUR WEB EXPORT PDF PRESET HERE for the name of your web PDF preset.

    When you run the batch convert script, the source should be InDesign, the target should be InDesign, and the “Run a script” dropdown should point to the 5-line javascript above that was saved.

    1. Peter Kahrel
      January 11, 2016

      Colin,

      Nice examples of scripts that are run as additional scripts in the batch processor. However, recently I realised (after a user reported some problems) that variable and function names in the additional script must be ringfenced so that they don’t interfere with similar names used in the script. For example, if the additional script uses a variable i, then this will throw off any variable i used in the batch processor.

      To ringfence the additional script, wrap it as follows:

      (function () {
      // your code goes here
      }());

      Peter

    2. October 22, 2015

      You’ll also need to swap the typographers quotes with straight quotes from my last post. That is something this commenting software has done to my script :(

      1. October 22, 2015

        Yes, sorry about that Colin. By default, our site CMS changes the quotes. If you want to avoid that in the future, use the code and pre html tags around it. For example:

        This is a test of typing some "double quotes" and some 'single quotes' around text.
             It should also save the spaces at the beginning of
             these lines
             which usually get stripped out.
        


        (Unfortunately, it also won’t wrap properly. We’ll see if we can fix that.)

  27. Rachel
    October 22, 2015

    Is there any way to change the names of the PDFs on export? For example I regularly produce two PDFs from the documents, called xxxx that need to be called xxxx nocrops.pdf and xxxx crops.pdf – I have these set up as a preset so can export with the correct setting but can’t see a way to change it so they don’t export as xxxx.pdf

  28. fi
    September 18, 2015

    Hi,

    This is great , it saved out all the single PDFs as I wanted but I dont appear to be able to save the PDF’s with Bleed or Cropped marks?? Have I missing something here? Please help!

    1. fi
      September 18, 2015

      Manage to get it with Bleeds! Incase any one esle was struggling. You need to set up a new Modified PDF preset in Indesign with what ever Bleeds,crop marks etc that your after. Once you have set that up , you can then select this PDF preset in the drop down in Batch process. :)

      1. August 31, 2016

        Thanks, what a great little workaround!

  29. Stefa
    July 14, 2015

    How do I run this script with Bleeds included in the export?
    Thanks

  30. Jay
    April 24, 2015

    I knew there had to be a quicker way! Thanks so much for this. Saved me from having to convert almost 200 InDesign files individually. This worked fantastically.

  31. Tony
    April 2, 2015

    Hi all,
    Is it possible to make this script exporting the predefined ranges? I have several indd documents, which are finaly joined into the book. And I need to export all pages but not as a single PDF, but some PDF are two pages (the most of) some more, some only one. And I know the pages, which should be in one PDF. Is it possible to use this (or other) script for this?
    Example: PDF1 contains pages 1-2, PDF2=3+4, PDF3=5 to 8, PDF4=9, etc.
    Thanks!

    1. Cheeky
      October 6, 2015

      Hi Tony,
      I’m using this script with the same problem. Did anyone ever give you an answer on this? I want to be able to specify pages for pdf export.

  32. February 12, 2015

    Pure genius! Thanks so much.

  33. Morgan
    November 11, 2014

    Sorry for the basic question, but how do I get the dialog box to open? When I click on the script, a notepad with jumbled text appears.

    1. Mathais
      November 12, 2014

      DON’T open the script in the finder or on your desktop! You must install it TO InDesign!

      So, install the script, then click (in the floating panel of InDesign) on the scripts name. Now, the dialogue should open.

  34. Kim
    November 3, 2014

    Is this a windows only script?

    1. Mathais
      November 4, 2014

      Screen shots are made on a Mac! I have a Mac, too! Does it work? YES! Enjoy!

      1. Kim
        November 4, 2014

        Thanks much!

  35. Mathais
    October 31, 2014

    Wow! Love that script! It’s worth a donation! (…I donated 10 GBP…)

    And thanks IDS for pointing me to this handy script!
    Mathais

  36. Gary Stolz
    August 13, 2014

    Thanks again. Today I used it to reduce 30 minutes of work to less than 30 seconds, and they all came out perfectly.

  37. David Ramirez
    August 8, 2014

    Hi Colin, you are right, when dealing with several documents you do what want to be sure that your files have no issues.
    The Copy Fonts to Folder script is awesome!

  38. David Ramirez
    August 6, 2014

    Colin, you had me intrigued: I believe a usual workflow when working for print is sending a pdf to a commercial printer as opposed to creating a package(because of the huge amount of data). So, when you know before hand that you will be sending a pdf (properly created with correct resolution, color profile, etc) then there is no need to create a package..so fonts you use will remain in the OS folder (e.g. Windows/Fonts) and not in the same directory of the Indesign file. Why would this result in a not “well-created file”?…if for some reason (like opening an Indesign file in another pc) fonts are missing, Indesign has many alarms that make sure you are aware of it.

    1. August 7, 2014

      Hello there David.

      It is important to note that Peter’s script has the ability to ignore error dialog boxes, so if InDesign files have missing links or fonts, it is possible for the script to ignore these warnings and output PDFs with unexpected results.

      My point being was if using the script with the “ignore errors” checkbox on, then one would want to make darn sure that the files were prepared in such a fashion that – if opened individually – none of the files would yield any errors as they were being opened – and this is what was meant by “well-created”.

      As for “usual workflow”… that all depends on the housekeeping of the designers supplying the artwork. Not everybody follows world’s best practice, and I’ve lost count of the amount of times over the years that I’ve had to contact clients because the final output PDF was not appropriate for print purposes (for dozens of reasons) or that the native artwork supplied – again – was not appropriate (again, for dozens of reasons).

  39. James Wamser
    August 5, 2014

    Thanks, this is REALLY useful. Thanks for stressing “well-created”… Working for a commercial printer, we see a lot of well-intended, but not always well-created files.

  40. Mike Wagner
    August 5, 2014

    Holy crap, this is amazing! I’m definitely going to have a use for this!

  41. Eugene Tyson
    August 5, 2014

    Amazing, I just wrote a sorta article on this earlier today. It’s a fantastic script and I highly recommend it.

  42. Gary Stolz
    August 5, 2014

    Wow. Thanks for this! It will be a HUGE productivity boost for me!