Export Pages To Subfolders

Script for Adobe InDesign
Latest update 3/31/2023, version 4.5

This is a variation of the script Export Named Pages, altered to instead export pages using the same file name, but each to a named subfolder.

  • Name by paragraph style or character style
  • Name by image, stacking order or object style
  • Export JPG, PDF (interactive or print), or PNG
  • Save and restore all settings
  • User-configurable localization
Download
Export Pages To Subfolders
Many scripts are free to download thanks to the support of users. Help me keep developing new scripts by supporting my work. Click the PayPal button to contribute any amount. Thank you.

How-to Video

How to use the script

The interface has four sections: File name, Folder, Output, and Settings. Set the desired options and click the OK button to begin. A progress bar is displayed as pages are exported.

Section 1: File name

Enter the desired file name shared by all pages exported. The default value is the name of the document.

Reset — restores file name to default (document name without extension).

Section 2: Folder

Root — the root folder to which subfolders are added, into which pages are exported. The default is the folder where the InDesign document is located. Click the button Root to select another. To the right is a button with three dots that opens another window with more output folder options.

Output folder more options
Output folder window

Here, recent folders are listed. Click one, and it becomes the output folder.

It’s also possible to set a folder as the default each time the script runs. Below the list is Default output folder. Click the button Set default, and choose the desired folder. Then whenever the script runs, the output folder is the same. Or leave the default (none), and it’s always where the document is located.

Subfolder name method:

Paragraph style — for each page, the first line of the first paragraph found on the page that is assigned the selected paragraph style is used to name the subfolder.

Character style — for each page, the first instance of text found on the page that is assigned the selected character style is used to name the subfolder.

Object style — for each page, the first image found on the page that is assigned the selected object style uses the image file name without extension to name the subfolder.

Image name — the file name without extension of the first image found on the page is used to name the subfolder. As of version 2.6, “images” includes all placed graphics, not only raster images, so now includes vector graphics as well. In the remaining instructions and interface options, the term “images” refers to placed graphics.

In all cases, “first” refers to the order elements are arranged, first being the highest element in the overall stacking order. This also takes into account layer order. The highest in stacking order, on the highest layer, is considered “first.” Use the next option to instead search from lowest to highest in stacking order.

Reverse search: match lowest element instead of highest — the elements to search through are reversed before searching, so that “first” to match becomes the lowest in stacking order rather than the highest.

Section 3: Output

Pages: All or Range — controls whether to export all pages of the document, a single page, or any range or ranges of pages. For a single page or a range, the normal InDesign rules for identifying pages are recognized. Use section and/or alternate layout prefixes combined with the page number as it appears in the layout, or enter the plus sign followed by the absolute page number. Separate the first and last pages of a range with a hyphen, and separate multiple pages or page ranges with a comma.

Pages or Spreads — from the drop-down list, choose to export either Pages or Spreads. When exporting spreads, the rules of how file names are determined remain the same, but elements on either page of the spreads are considered, including stacking order, rather than only elements on a single page.

In groups of (PDF formats only) — PDF output has the option to export pages in groups of any number. Enter '1' for single page PDFs. Enter '2' for front + back in each PDF output, for example, or any other reason to group every 2 pages of the document into a single PDF. Or enter any number of pages desired to create PDFs that each contain the entered number of pages. Once the end of the document is reached, the balance of pages not yet output make up the final PDF, even if not reaching the specified number of pages. When exporting spreads, the value to group applies to spreads rather than pages. In either case, folder names based on page content are determined by the first page or spread of the group, and subsequent page content is ignored.

Export PDF single or front+back

Replace existing output files — when enabled, existing output folders are replaced without user intervention. When disabled and an existing folder is detected, an incremental number is added to the folder name to prevent overwriting the existing folder.

IMPORTANT: when enabled, any pages exported that resolve to the same name as any prior page overwrites all output folders of the same name. Ensure the document set up and options selected result in unique names for each page. If in doubt, disable this option and folder names that conflict with pages already exported have a version number appended to prevent overwriting.

Format — the file format to which pages are exported. The available choices are JPG, PDF (Interactive), PDF (Print), and PNG. Each format offers different options described next.

JPG

Resolution — pixels per inch used to rasterize the pages.

Color Space — choose RGB, CMYK, or Gray.

Quality — choose Maximum, High, Medium, or Low.

Bleed — includes document bleed, if any.

Embed Profile — embeds the current color profile.

PDF (Interactive)

Resolution — pixels per inch for images.

Quality — image quality. Choose Maximum, High, Medium, or Low.

Export in background — when enabled, PDFs are queued to export in the background, and the script ends sooner. When disabled, each PDF page is exported immediately, and the script is active until all PDFs are exported. When exporting a great number of pages, it is best to disable this option.

Create Acrobat Layers — enable to save each InDesign layer as an Acrobat layer within the PDF.

PDF (Print)

PDF preset — the PDF preset used to export the pages.

Export in background — when enabled, PDFs are queued to export in the background, and the script ends sooner. When disabled, each PDF page is exported immediately, and the script is active until all PDFs are exported. When exporting a great number of pages, it is best to disable this option.

PNG

Resolution — pixels per inch used to rasterize the pages.

Color Space — choose RGB or Gray.

Quality — choose Maximum, High, Medium, or Low.

Bleed — includes document bleed, if any.

Transparent — areas of the page uncolored are transparent.

A note about JPG and PNG: there isn’t an option for anti-alias because the script always enables anti-alias when exporting either image format. I couldn’t imagine a need to disable the option considering that without anti-alias, the result is horrible. But perhaps I could be wrong, and there is a need to disable it. Contact me to share other views on the subject.

Section 4: Settings

The current options may be saved and restored later. Select from the Load drop-down list to choose saved settings, and the current options are updated. Click the Delete button, and the saved settings selected in the Load drop-down list are permanently removed. Click the Save button, provide a name for the settings, and the current options are preserved. If the name already exists, the user may choose to replace the saved settings. Or click the checkbox Replace settings, and choose the settings to replace.

The script provides default saved settings named [Default]. These settings cannot be deleted but may be updated to the current values. Save settings, click the checkbox Replace settings, and choose [Default].

When settings are saved, there is also the option to include File name and/or Output folder.

Export Pages To Subfolders Save settings

Each time the script is launched, the file name defaults to the InDesign document name without extension, and the output folder defaults to the location of the InDesign document. To override these defaults, enable the options to include File name and/or Output folder. Then when the saved settings are loaded, the file name and/or output folder are restored to the values set when the settings were saved. This includes the next launch of the script, as the last settings selected are also restored.

Language

By default the script language is US English, which does not require further download or configuration. To have the script interface display other languages, choose from the available languages below. Download and copy the .i18n file to the script folder alongside the script. When launched, the script detects the language file and displays interface text in that language. If your language is not listed, download the English file and translate it. The file is plain text formatted as JSON, containing interface text in English, and a second value for its translation, which for the English file is the identical text. Copy the file and rename it to replace “en” with the relevant code for your language, then edit the file to change each line’s second value to the translation in your language. For more detailed instructions of how to edit and install i18n files, see How to Localize Scripts.

English: export-pages-to-subfolders-en-i18n.zip

Many scripts are free to download thanks to the support of users. Help me keep developing new scripts by supporting my work. Click the PayPal button to contribute any amount. Thank you.
Download
Export Pages To Subfolders

Change log: export-pages-to-subfolders.txt

For help installing scripts, see How to Install and Use Scripts in Adobe Creative Cloud Applications.

Custom solutions based on any script, or completely new ideas, are possible at reasonable cost. Contact William for more information.

IMPORTANT: by downloading any of the scripts on this page you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.

IMPORTANT: fees paid for products purchased from this site, or for programming custom solutions, are the purchase of a non-exclusive license to use the software and do not grant the purchaser any degree of ownership of the software. Author of the intellectual property and copyright holder William Campbell retains 100% ownership of all code used in all products and custom solutions.

IMPORTANT: scripts are developed for the latest Adobe Creative Cloud applications. Many scripts work in CC 2018 and later, even some as far back as CS6, but may not perform as expected, or run at all, when used in versions prior to 2018. Photoshop features Select Subject and Preserve Details 2.0 definitely fail prior to CC 2018 (version 19) as the features do not exist in earlier versions. For best results use the latest versions of Adobe Creative Cloud applications.