Batch-process (convert/export/import) documents

The script (batch) processes files. It can be used to export InDesign documents to PDF and other formats, to convert QuarkExpress and PageMaker documents to InDesign, to update large numbers of InDesign documents to the latest InDesign version, to downsave documents to previous versions of InDesign (see Downsaving to earlier InDesign versions), and to place Word (and rtf) files either in a single InDesign document or in separate documents.

In addition to converting documents, the script can be used to run another script against all selected documents. Thus, if you select InDesign as the source and the target format, the documents aren't converted, you just run the specified script against all documents. (That script can be JavaScript, compiled AppleScript, or Visual Basic.)

Use

With no documents open, the script displays the dialog shown in the screen shot. At Input folder you enter the location of the files that you want to process; to browse to a folder, click the folder icon. To type a folder name, use the platform-neutral format (/d/test) or any of the platform-specific forms (d:/test or d:\\test on Windows; note the doubled backslashes in the second format). The ten last-used folders are shown in the dropdown.

batch convert and process InDesign PDF INX HTML SWF EPS IDML PageMaker Quark Express Package

After selecting the input folder, its name is entered at Output folder but you can change that either by selecting a folder using the folder icon or by typing its name. To overwrite existing files, tick Overwrite existing files. If you choose not to overwrite existing files, the script adds number suffixes to file names.

Tick Include subfolders to process all subfolders of the selected folder. To keep the converted files in the same folder as the source files, leave the Output folder field empty. If you do specify an output folder and include subfolders, all files are placed together in that output folder.

Tick Ignore errors to ignore errors such as missing fonts and missing links and links that are out-of-date.

Select the source and destination formats in the Source and Target dropdowns. Available options in the source dropdown are InDesign, InDesign book, InDesign (template), INX (CS3 and later), IDML (CS4 and later), PageMaker (up to CC: CS6 is the last InDesign version that supports opening PageMaker files), QuarkExpress, and Word/RTF.

The output formats are InDesign, InDesign (template), INX (CS3 and 4), IDML (CS4 and later), ICML, PDF, interactive PDF, EPS, RTF, XML, JPG, PNG (from CS6), HTML (from CS5.5), packaging (from CS5), and SWF (CC). Word/RTF documents can be saved individually or as a single document; see Word and RTF files, below, for details.

Instead of choosing a folder to select files to convert, you can convert any open documents. If any documents are open, 'Input folder', 'Include subfolders', and the source formats can't be selected.

PDF export options/presets

Select the PDF preset from the list. You can specify more than one PDF preset for export to PDF. For example, in the screenshot, above, four presets are selected: _print, _proof, archive, and _web. When you select a preset whose name starts with the underscore character, a PDF is created using that preset and the preset's name is added to the PDF's name. If the preset name's first character is not an underscore, its name is not added. Thus, if a document named test.indd is exported using the presets shown in the screenshot, these three PDFs will be created: test.pdf, test_print.pdf, test_proof.pdf, and test_web.pdf. In this example, test.pdf was exported using the archive preset: the preset's name was not added because its name doesn't start with an underscore.

Export InDesign documents to PDF as separate pages

The script can export document pages as separate PDFs. The names of PDF files are constructed by combining the InDesign document's name and a three-digit sequential number, which is either the printed document page number or page's document offset. Thus, if you have a two-page document named test.indd and the first page number is 5, then using page numbers produces test_005.pdf and test_006.pdf. On the other hand, when you use offsets, the two PDF files are named test_001.pdf and test_002.pdf.

Note that from CC2018 InDesign can export separate pages natively. If you want to use that feature, set it in the job option(s) and don't use the script's function. To use the script's page-by-page export function, simply don't set it in the PDF job option.

View PDFs after exporting

This performs the same function as the one in InDesign's PDF export dialog: it opens all exported PDFs. This is not a good idea when you export large numbers of documents, but the option lets you override the preset.

Custom presets: HTML, JPG, AEM

PDF is the only export format for which Adobe provides presets. All other formats use either the application's or the current document's settings. (JPEG, EPS, PNG, PDF, and SWF are application settings; EPUB and HTML are document settings; XML export is a property of both the application and the document.)

For application settings you need to prime InDesign: open a document, set the desired export settings, export the document, and discard it. The application is now primed for your settings and any document uses those settings when it is exported.

When you export to EPUB, HTML, or XML, the document settings are used. If you don't want to use document preferences you'll have to create your own presets.

The converter comes with tools to create presets for HTML, JPG, and AEM; see below for details.

HTML export presets

If you want to use each document's own HTML export properties, select [None] in the dropdown.

AEM export presets

To export documents to AEM, you must create and install at least one AEM export preset. See AEM export presets, below, for details. For more details on AEM export, see Keith Gilbert's article on InDesign Secrets.

Preserve folder structure when packaging

Checked: The folder structure of the selected input folder is duplicated under the selected output folder, so that each packaged document is in its own subfolder. This mimics InDesign's behaviour: a folder is created for each file and named after the InDesign file; the InDesign file is placed in that folder together with the PDF and IDML files (if their inclusion was selected), and if fonts and/or links are included, a subfolder is created for each. Unchecked: All documents are packaged to the same folder (and all links to the same Links folder, and all fonts to the same Document Fonts folder).

The PDF export part of packaging is sensitive to the PDF export presets you select in the PDF panel.

Include JPEG/PNG

To set the export properties of these two formats, prime InDesign: open a document and export it to JPEG and or PNG using the settings you want for all documents. Now when you run the batch processor, the script will use the export properties you applied.

ICML files

Each document's story is exported using the document's name and the story's id. Stories on master spreads are ignored.

Word and RTF files

Word (both doc and docx) and RTF files can be placed in one or more InDesign documents. Select Word in the Source dropdown and InDesign as the target format to convert each Word file to a separate InDesign document. To combine all Word documents in a single InDesign document, choose InDesign single document as the target format.

When you place all Word files in a single InDesign document, the files are placed in alphabetical order, that is, in the order in which they appear in the file list. File names are printed at the beginning of each Word text so that it's easy to find the beginning of those Word texts. File names are placed between strings of ampersands, as in &&&test.docx&&&.

It's possible to place the Word documents in an existing InDesign document. The script looks in the output folder for a file named Word_InDesign_Template.indd or Word_InDesign_Template.idml (in that order). If that's found, the script places all Word content in it. If the file isn't there, the script simply creates a new blank document. If you use such a template file and you want the Word content to flow into the document automatically, enable Smart Text Reflow in the document.

Convert text to outlines

This option is available only if you export to EPS.

Close open documents

This option is available only if any documents were open when you started the script.

Run a script

You can choose to run one or more scripts during the export or conversion; these scripts can be JavaScript, compiled AppleScript, or Visual Basic. (When you run more than one script they must all be the same type.) The scripts run on every document you export. The scripts you want to run must be in the same folder as the folder where the batch converter is run from or in a subfolder. (Scripts cannot be run against books.)

To enter a script, type its full name in the field or use the folder icon to select one or more scripts. When you enter script names manually, separate the names with commas or semicolons. The scripts are executed in the order in which you enter them.

If you choose InDesign as both source and target format and select a script, you can in effect use the batch processor as a batch script runner.

Important: Make sure that variables and functions defined in your scripts do not clash with variables and functions in the batch processor. The best way to do this is to place your script in a so-called anonymous function and declare all variables, as follows:

(function () {
   myDoc = app.activeDocument;  	// wrong (undeclared variable myDoc)
   var myDoc = app.activeDocument;	// correct
   // more code
}());

In line 2, myDoc is not declared as a variable and can interfere with a variable of the same name in the batch processor (if it had one). In line 3, myDoc is declared as a variable by adding the word var before it, restricting the scope of myDoc to this particular function. I don't know if this is relevant for AppleScripts and VB scripts.

See Colin Flashman's post on InDesign Secrets for some interesting examples.

Save documents on closing

Check this box if you're running a script during the conversion or export and want to save the changes the script made.

Batch processor preset

The current window's settings are always stored when you press OK to start the script. The file is called batch_convert.txt and lives in your script folder and is read when next you run the script.

In addition, you can save certain window layouts in presets. These presets are not saved automatically, you must do that yourself, using the familiar icon to the right of the dropdown. The next time you run the script, the last-used preset is selected. Presets are stored in your script folder using the file extension batch_preset.


Creating HTML presets

HTML export properties are properties of a document, not, as most other export properties, of the application. Therefore, if you want to batch-export documents to HTML, you have to create your own preset.

InDesign doesn't support HTML export presets, but the script can use presets that you create yourself in a format that the script recognises. Creating those presets is very simple. Before you run the batch processor, do as follows:

  1. Start a new document.
  2. Open the HTML Export dialog and set all options. There's no need to view the HTML after exporting, so you can disable this function in the General tab of the export options. Click OK to export the document so that the export options are set in the document.
  3. Run the script html_save_preset.jsx, which is included in the download. In the script's dialog, enter the name for the preset and click OK:
    Create HTML preset
    If you enter a name that's already in use, the script asks you if you want to replace the preset with that name. This script is a bit cludgy in that if you answer 'No', the script terminates and you'll need to start it again.
  4. You can now delete the HTML file that you exported in step 2.

HTML presets are stored in your scripts folder and use the file type html_preset. They are plain text files.

Creating JPG presets

This is similar HTML presets. Retrieve jpeg_save_preset.jsx from the preset zip file and use it as described for the HTML preset.

Creating AEM export presets

To export AEM Mobile articles, you must prepare at least one export preset. InDesign doesn't provide any facilities in the form of presets comparable with PDF export presets, you have to create them yourself. AEM presets are pretty simple, the zip download contains an example.

Preset files must use the extension (file type) AEM_preset (case-insensitive). For full details on export properties, see AEM Mobile export properties. They are plain text files. They should be stored in the same folder as the batch converter script.


Troubleshooting

If the script won't run, please delete the file batch_convert.txt, which lives in the script's folder. (This file is used to store the dialog's settings.) To delete it, open the Scripts panel and make sure that the Display Unsupported File option is checked. Then look for the file in the list; see the screenshot:

remove a script file


Downsaving to earlier InDesign versions

You can downsave documents to a previous version via one or both of the interchange formats INX and IDML. The success of downsaving is variable, it depends on the features present in a document. Features introduced in, say, CS5 naturally do not survive when you save a document down to an earlier version.

Before you downsave, consider the Indesign versions. Often it will be a multi-step operation because of a change in the interchange format.

CS3: reads and writes INX

CS4: reads and writes INX and IDML

CS5 and later: read INX, read and write IDML

If you want to downsave, say, CS6 to CS3, you need to export the CS6 file to IDML, then open CS4 and convert IDML to INX.

From CS6, InDesign natively supports downsaving.


Version history

14 Mar. 2024: When packaging files and including PDFs, the script no opens the PDFs.

17 Feb. 2024: The script didn't handle books (indb) correctly. Fixed.

30 May 2023: Linked InDesign files caused all kinds of problems when the script was run against one or more open documents. Fixed.

25 May 2023: The 'Close open documents' checkbox wasn't set correctly from the history file when the script was started. Fixed.

25 Sept. 2022: The script crashed in older versions of InDesign because of an unguarded call to interactive PDF export. Fixed.

1 Aug. 2021: You can now add more than one script in the 'Run a script' field. See the text for details.

2 Feb. 2019: (a) Added support for JPEG export presets; (b) the script didn't detect InDesign CS6.1 correctly, now it does.

13 Dec. 2018: Added two packaging options: 'Include document hyphenation exceptions only' (available from CC2018) and 'Include report' (that's the instructions.txt file; exposed in the interface from CC2019).

6 Oct. 2018: A bug had crept in that caused the script to ignore the state of the 'View PDF' checkbox. Fixed.

20 Aug. 2018: Added support for ICML export.

13 May 2018: Added a note about InDesign's new page-by-page PDF export functionality.

17 Mar. 2018: Added support for AEM Mobile export.

8 June 2017: Fixed a problem with handling file names containing %-symbols.

7 Mar. 2017: Added InDesign books as a source format. Export to PDF only.

4 Mar. 2017: (a) Choosing a script now pops up an OS file dialog that shows the script folder so that scripts can be selected from subfolders; (b) the state of the 'Save changed documents on closing' checkbox wasn't selected when the scripts was started; fixed.

29 Jan. 2017: Improved the logistics of linking a script; added some functionality to the processing of Word and RTF files (see Word and RTF files).

2 Jan. 2017: Split the export-per-page PDF option into using page numbers and offsets for sequential numbers.

4 Sept. 2016: Added inclusion of JPEG and PNG as an option in packaging.

4 Sept. 2016: Fixed a problem with restoring the dialog settings from the previous session.

4 Sept. 2016: When you select Word as the source type, the target list now includes the item 'InDesign single document'. Therefore it's now possible to convert each Word (or rtf) file to a separate Indesign file, or place them all in a single InDesign document.

21 Aug. 2016: The PDF preset dropdown is now a multi-select list box. This means that it's now possible to produce several PDFs from a single InDesign document using multiple PDF presets. See PDF presets for details.

21 Aug. 2016: Added 'Word' as a source format. You can now convert folderfuls of rtf, doc, and docx files to InDesign. Each Word file is converted to a separate InDesign file.

19 Oct. 2015: PageMaker support was dropped in InDesign CC, so from CC the PageMaker option doesn't appear in the Source dropdown.

11 Sept. 2015: Added a cautionary note on running scripts inside the batch processor (the script is unchanged). See here.

23 July 2015: 'Run a script' now supports AppleScript and Visual Basic scripts in addition to JavaScripts. AppleScripts must be compiled to .scpt files.

25 March 2015: Single-page PDFs were exported to the wrong folder – fixed.

24 March 2015: Added single-page export for PDF.

10 Feb. 2015: There was a problem displaying the names of some files. Fixed by replacing the message window with a progress bar.

15 Oct. 2014: Fixed the behaviour of the 'Preserve folder structure' option; see the text for details.

12 Oct. 2014: Added various packaging options.

12 Sept. 2014: The script now ignores folders and files whose names start with a dot.

28 November 2013: (1) Added a checkbox so you can choose to overwrite existing files. If the box is not ticked, numbered suffixes are added to file names. (2) Added presets, so now you can store and retrieve different window configurations.

10 August 2013: INX files can be read by all InDesign versions, not just up to CS4. Fixed.

5 July 2013: Added support for SWF export (introduced in CC).

24 March 2013: Added support for HTML export presets; see Creating HTML presets.

14 February 2013: There were reports of problems with exporting to EPS/Convert to outlines enabled. Fixed.

27 November 2012: (1) Added interactive PDF as an export format. (2) Added the option to disable the tooltips.

22 November 2012: Added the option to preserve folder structure when packaging documents. See the text for details.

20 November 2012: CS4 appears not to like the dropdown for the folders. For CS4 the script therefore reverts to the last used folder only. In later CS versions and in CC the dropdown works fine.

9 November 2012: (1) Added tooltips to several dialog items to clarify their purpose. (2) The Input folder field now incorporates a dropdown with the last ten folders used. The output folder continues to display only the last-used folder.

27 June 2012: Added HTML (available from CS5.5).

23 April 2012: Added PNG as an export format (from CS6).

20 February 2012: Fixed a bug that caused an undefined error.

1 November 2011: Rewrote the interface. Documents can now be saved after running a script.

31 October 2011: Added an option to run a script before a file is exported or converted. See text for details.

25 January 2011: Fixed problem with error reporting.

13 January 2011: Added QuarkXPress as a source document type.

1 January 2011: Added packaging.

29 December 2010: Fixed problem with unrecognised format error; PDF View preference wasn't restored: fixed.

2 December 2010: PageMaker conversion now recognises the PMD, PM6, and P65 file extensions: pick PageMaker and all files with any of these extensions are converted.

30 November 2010: Added PageMaker conversion.

Sometime in 2003: First posted.


Useful script? Saved you lots of time?

Consider making a donation. To make a donation, please press the button below. This is Paypal's payment system; you don't need a Paypal account to use it: you can use several types/brands of credit and debit card.

Peter Kahrel's paypal account

Download script

Download presets

Back to script index

Installing and running scripts

Questions, comments? Get in touch