Batch Export

Script for Adobe InDesign

Export a folder of InDesign documents to a variety of file formats.

  • Export ICML, IDML, JPG, PNG
  • Export PDF interactive or print
  • Option to update links and save
  • Option to include subfolders
  • Add suffix to output file names
  • Adapt open source to customize or create other scripts
Download
Batch Export
Help me keep making new scripts by supporting my work. Click the PayPal button to contribute any amount you choose. Thank you. William Campbell

How-to Video

How to use the script

The interface has three sections: Input, Options, and Output. Set desired options and click the OK button to begin. A progress bar is displayed as documents are processed.

Section 1: Input

Folder — click the button to select a folder that contains InDesign documents. Each document in the folder is exported to the format specified in the Output section. Only files with the .indd extension are processed.

Include subfolders — if enabled, documents in all subfolders are also processed.

Section 2: Options

Update links and save — when enabled, for each document opened, any placed graphics that are modified are updated, and the document is saved before exporting.

Section 3: Output

Folder — click the button to select the folder to which documents are exported.

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

Spreads — enable to output pages in spreads. Applies to formats JPG, PDF (Interactive), and PNG.

ICML

InCopy Markup Language.

Include graphic proxies — when enabled, export includes graphic proxy data.

Include all resources — when enabled, export includes all resources (styles, etc.), otherwise export only includes resources used by each story.

Unlike other formats, the option to export ICML does not output document pages, rather the script outputs the contents of document text frames. For any story that spans multiple text frames, the first text frame is exported, which includes all content of the story, and remaining text frames of the thread are ignored.

IDML

InDesign Markup Language.

There are no options when exporting InDesign Markup Language.

JPG

Resolution — pixels per inch used to rasterize the pages. Valid range is 1 to 2400.

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

Color Space — choose RGB, CMYK, or Gray.

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.

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

Tagged — enable to create a tagged PDF.

PDF (Print)

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

PNG

Resolution — pixels per inch used to rasterize the pages. Valid range is 1 to 2400.

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

Color Space — choose RGB or Gray.

Bleed — includes document bleed, if any.

Transparent — areas of the page uncolored are transparent.

Original file name + — a suffix of characters appended to each output file name. The characters entered must be legal to use in file names. Any illegal characters are automatically removed. Having no suffix is allowed, in which case output file names exactly match input file names.

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.

Source code

(download button below)

/*

Batch Export
Copyright 2024 William Campbell
All Rights Reserved
https://www.marspremedia.com/contact

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

(function () {

    var title = "Batch Export";

    if (!/indesign/i.test(app.name)) {
        alert("Script for InDesign", title, false);
        return;
    }

    // Script variables.
    var colorSpaceEnumsJpg;
    var colorSpaceEnumsPng;
    var colorSpacesJpg;
    var colorSpacesPng;
    var doneMessage;
    var error;
    var extension;
    var extensions;
    var folderInput;
    var folderOutput;
    var format;
    var formats;
    var pdfPreset;
    var pdfPresetNames;
    var progress;
    var qualities;
    var qualityEnumsJpg;
    var qualityEnumsPdf;
    var qualityEnumsPng;

    // Reusable UI variables.
    var g; // group
    var gc1; // group (column)
    var gc2; // group (column)
    var gc3; // group (column)
    var p; // panel
    var w; // window

    // Permanent UI variables.
    var btnCancel;
    var btnFolderInput;
    var btnFolderOutput;
    var btnOk;
    var cbAllResourcesIcml;
    var cbBleedJpg;
    var cbBleedPng;
    var cbEmbedProfile;
    var cbGraphicProxiesIcml;
    var cbLayersPDFInteractive;
    var cbSpreads;
    var cbSubfolders;
    var cbTaggedPDFInteractive;
    var cbTransparentPng;
    var cbUpdateSave;
    var grpFormats;
    var inpResolutionJpg;
    var inpResolutionPDFInteractive;
    var inpResolutionPng;
    var inpSuffix;
    var listColorSpaceJpg;
    var listColorSpacePng;
    var listFormat;
    var listPdfPreset;
    var listQualityJpg;
    var listQualityPng;
    var listQualityPDFInteractive;
    var stack;
    var txtFolderInput;
    var txtFolderOutput;

    // LANGUAGE EXTENSIONS

    if (!String.prototype.trim) {
        String.prototype.trim = function () {
            return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
        };
    }

    // SETUP

    colorSpaceEnumsJpg = [
        JpegColorSpaceEnum.RGB,
        JpegColorSpaceEnum.CMYK,
        JpegColorSpaceEnum.GRAY
    ];
    colorSpaceEnumsPng = [
        PNGColorSpaceEnum.RGB,
        PNGColorSpaceEnum.GRAY
    ];
    colorSpacesJpg = [
        "RGB",
        "CMYK",
        "Gray"
    ];
    colorSpacesPng = [
        "RGB",
        "Gray"
    ];
    extensions = [
        "icml",
        "idml",
        "jpg",
        "pdf",
        "pdf",
        "png"
    ];
    formats = [
        "ICML",
        "IDML",
        "JPG",
        "PDF (interactive)",
        "PDF (print)",
        "PNG"
    ];
    qualities = [
        "Maximum",
        "High",
        "Medium",
        "Low"
    ];
    qualityEnumsJpg = [
        JPEGOptionsQuality.MAXIMUM,
        JPEGOptionsQuality.HIGH,
        JPEGOptionsQuality.MEDIUM,
        JPEGOptionsQuality.LOW
    ];
    qualityEnumsPdf = [
        PDFJPEGQualityOptions.MAXIMUM,
        PDFJPEGQualityOptions.HIGH,
        PDFJPEGQualityOptions.MEDIUM,
        PDFJPEGQualityOptions.LOW
    ];
    qualityEnumsPng = [
        PNGQualityEnum.MAXIMUM,
        PNGQualityEnum.HIGH,
        PNGQualityEnum.MEDIUM,
        PNGQualityEnum.LOW
    ];
    grpFormats = [];

    // Load application PDF presets.
    pdfPresetNames = app.pdfExportPresets.everyItem().name;
    pdfPresetNames.sort();

    // CREATE PROGRESS WINDOW

    progress = new Window("palette", "Progress", undefined, {
        "closeButton": false
    });
    progress.t = progress.add("statictext");
    progress.t.preferredSize.width = 450;
    progress.b = progress.add("progressbar");
    progress.b.preferredSize.width = 450;
    progress.display = function (message) {
        message && (this.t.text = message);
        this.show();
        this.update();
    };
    progress.increment = function () {
        this.b.value++;
    };
    progress.set = function (steps) {
        this.b.value = 0;
        this.b.minvalue = 0;
        this.b.maxvalue = steps;
    };

    // CREATE USER INTERFACE

    w = new Window("dialog", title);
    w.alignChildren = "fill";

    // Panel 'Input'
    p = w.add("panel", undefined, "Input");
    p.alignChildren = "left";
    p.margins = [18, 18, 18, 12];
    g = p.add("group");
    btnFolderInput = g.add("button", undefined, "Folder...");
    txtFolderInput = g.add("statictext", undefined, "", {
        truncate: "middle"
    });
    txtFolderInput.preferredSize.width = 300;
    g = p.add("group");
    g.margins = [0, 6, 0, 0];
    cbSubfolders = g.add("checkbox", undefined, "Include subfolders");

    // Panel 'Options'
    p = w.add("panel", undefined, "Options");
    p.alignChildren = "left";
    p.margins = [18, 18, 18, 12];
    cbUpdateSave = p.add("checkbox", undefined, "Update links and save");

    // Panel 'Output'
    p = w.add("panel", undefined, "Output");
    p.alignChildren = "left";
    p.margins = [18, 18, 18, 12];
    g = p.add("group");
    btnFolderOutput = g.add("button", undefined, "Folder...");
    txtFolderOutput = g.add("statictext", undefined, "", {
        truncate: "middle"
    });
    txtFolderOutput.preferredSize.width = 300;
    g = p.add("group");
    g.margins = [0, 6, 0, 0];
    g.add("statictext", undefined, "Format:");
    listFormat = g.add("dropdownlist", undefined, formats);
    listFormat.selection = 4;
    g = g.add("group");
    g.margins = [12, 3, 0, -3];
    cbSpreads = g.add("checkbox", undefined, "Spreads");
    cbSpreads.visible = false;
    // Stack
    stack = p.add("group");
    stack.alignChildren = "left";
    stack.orientation = "stack";
    // ICML
    grpFormats[0] = stack.add("group");
    grpFormats[0].alignChildren = "left";
    grpFormats[0].orientation = "column";
    cbGraphicProxiesIcml = grpFormats[0].add("checkbox", undefined, "Include graphic proxies");
    cbGraphicProxiesIcml.value = true;
    cbAllResourcesIcml = grpFormats[0].add("checkbox", undefined, "Include all resources");
    grpFormats[0].visible = false;
    // IDML
    grpFormats[1] = stack.add("group");
    grpFormats[1].alignChildren = "left";
    grpFormats[1].orientation = "column";
    g = grpFormats[1].add("group");
    g.add("statictext", undefined, "(no options)");
    grpFormats[1].visible = false;
    // JPG
    grpFormats[2] = stack.add("group");
    grpFormats[2].alignChildren = "left";
    grpFormats[2].orientation = "column";
    g = grpFormats[2].add("group");
    g.add("statictext", undefined, "Resolution:");
    inpResolutionJpg = g.add("edittext");
    inpResolutionJpg.preferredSize.width = 70;
    inpResolutionJpg.text = "72";
    g.add("statictext", undefined, "Quality:");
    listQualityJpg = g.add("dropdownlist", undefined, qualities);
    listQualityJpg.preferredSize.width = 90;
    listQualityJpg.selection = 2;
    g = grpFormats[2].add("group");
    g.add("statictext", undefined, "Color space:");
    listColorSpaceJpg = g.add("dropdownlist", undefined, colorSpacesJpg);
    listColorSpaceJpg.preferredSize.width = 63;
    listColorSpaceJpg.selection = 0;
    g = g.add("group");
    g.margins = [0, 3, 0, -3];
    cbBleedJpg = g.add("checkbox", undefined, "Bleed");
    cbEmbedProfile = g.add("checkbox", undefined, "Embed profile");
    cbEmbedProfile.value = true;
    grpFormats[2].visible = false;
    // PDF (interactive)
    grpFormats[3] = stack.add("group");
    grpFormats[3].alignChildren = "left";
    grpFormats[3].orientation = "column";
    // Group of 3 columns
    g = grpFormats[3].add("group");
    // Groups, columns 1, 2, and 3.
    gc1 = g.add("group");
    gc1.alignChildren = "left";
    gc1.orientation = "column";
    gc1.spacing = 14;
    gc2 = g.add("group");
    gc2.alignChildren = "left";
    gc2.margins = [0, 0, 18, 0];
    gc2.orientation = "column";
    gc2.spacing = 6;
    gc3 = g.add("group");
    gc3.alignChildren = "left";
    gc3.orientation = "column";
    gc3.spacing = 11;
    // Rows.
    gc1.add("statictext", undefined, "Resolution (ppi):");
    inpResolutionPDFInteractive = gc2.add("edittext");
    inpResolutionPDFInteractive.preferredSize.width = 70;
    inpResolutionPDFInteractive.text = "144";
    g = gc3.add("group");
    g.add("statictext", undefined, "Quality:");
    listQualityPDFInteractive = g.add("dropdownlist", undefined, qualities);
    listQualityPDFInteractive.preferredSize.width = 90;
    listQualityPDFInteractive.selection = 2;
    g = grpFormats[3].add("group");
    cbLayersPDFInteractive = g.add("checkbox", undefined, "Layers");
    cbTaggedPDFInteractive = g.add("checkbox", undefined, "Tagged");
    grpFormats[3].visible = false;
    // PDF (print)
    grpFormats[4] = stack.add("group");
    grpFormats[4].alignChildren = "left";
    grpFormats[4].orientation = "column";
    g = grpFormats[4].add("group");
    g.add("statictext", undefined, "PDF preset:");
    listPdfPreset = g.add("dropdownlist", undefined, pdfPresetNames);
    listPdfPreset.selection = 0;
    grpFormats[4].visible = true;
    // PNG
    grpFormats[5] = stack.add("group");
    grpFormats[5].alignChildren = "left";
    grpFormats[5].orientation = "column";
    g = grpFormats[5].add("group");
    g.add("statictext", undefined, "Resolution:");
    inpResolutionPng = g.add("edittext");
    inpResolutionPng.preferredSize.width = 70;
    inpResolutionPng.text = "72";
    g.add("statictext", undefined, "Quality:");
    listQualityPng = g.add("dropdownlist", undefined, qualities);
    listQualityPng.preferredSize.width = 90;
    listQualityPng.selection = 2;
    g = grpFormats[5].add("group");
    g.add("statictext", undefined, "Color space:");
    listColorSpacePng = g.add("dropdownlist", undefined, colorSpacesPng);
    listColorSpacePng.preferredSize.width = 63;
    listColorSpacePng.selection = 0;
    g = g.add("group");
    g.margins = [0, 3, 0, -3];
    cbBleedPng = g.add("checkbox", undefined, "Bleed");
    cbTransparentPng = g.add("checkbox", undefined, "Transparent");
    grpFormats[5].visible = false;
    // Suffix
    g = p.add("group");
    g.add("statictext", undefined, "Original file name  +");
    inpSuffix = g.add("edittext");
    inpSuffix.characters = 18;

    // Action Buttons
    g = w.add("group");
    g.alignment = "center";
    btnOk = g.add("button", undefined, "OK");
    btnCancel = g.add("button", undefined, "Cancel");

    // Panel Copyright
    p = w.add("panel");
    p.add("statictext", undefined, "Copyright 2024 William Campbell");

    // UI ELEMENT EVENT HANDLERS

    // Panel 'Input'
    btnFolderInput.onClick = function () {
        var f = Folder.selectDialog("Select folder to process", txtFolderInput.text);
        if (f) {
            txtFolderInput.text = Folder.decode(f.fullName);
        }
    };

    // Panel 'Output'
    btnFolderOutput.onClick = function () {
        var f = Folder.selectDialog();
        if (f) {
            txtFolderOutput.text = f.fullName;
        }
    };
    listFormat.onChange = function () {
        for (var i = 0; i < grpFormats.length; i++) {
            grpFormats[i].visible = this.selection.index == i;
        }
        cbSpreads.visible =
            this.selection.index == 2 ||
            this.selection.index == 3 ||
            this.selection.index == 5;
    };
    inpResolutionJpg.onChange = function () {
        var n = parseInt(this.text, 10) || 0;
        if (n < 1 || n > 2400) {
            this.text = "72";
            alert("Valid range 1-2400. Value set to default.", " ", false);
        }
    };
    inpResolutionPDFInteractive.onChange = function () {
        var n = parseInt(this.text, 10) || 0;
        if (n < 72 || n > 300) {
            this.text = "144";
            alert("Valid range 72-300. Value set to default.", " ", false);
        }
    };
    inpResolutionPng.onChange = function () {
        var n = parseInt(this.text, 10) || 0;
        if (n < 1 || n > 2400) {
            this.text = "72";
            alert("Valid range 1-2400. Value set to default.", " ", false);
        }
    };
    inpSuffix.onChange = function () {
        // Trim.
        this.text = this.text.trim();
        // Remove illegal characters.
        var s = this.text.replace(/[\/\\:*?"<>|]/g, "");
        if (s != this.text) {
            this.text = s;
            alert("Illegal characters removed", " ", false);
        }
    };

    // Action Buttons
    btnOk.onClick = function () {
        folderInput = new Folder(txtFolderInput.text);
        if (!(folderInput && folderInput.exists)) {
            alert("Select folder to process", " ", false);
            return;
        }
        folderOutput = new Folder(txtFolderOutput.text);
        if (!(folderOutput && folderOutput.exists)) {
            alert("Select output folder", " ", false);
            return;
        }
        w.close(1);
    };
    btnCancel.onClick = function () {
        w.close(0);
    };

    // DISPLAY THE DIALOG

    if (w.show() == 1) {
        doneMessage = "";
        try {
            process();
            doneMessage = doneMessage || "Done";
        } catch (e) {
            error = error || e;
            doneMessage = "An error has occurred.\nLine " + error.line + ": " + error.message;
        }
        progress.close();
        doneMessage && alert(doneMessage, title, error);
    }

    //====================================================================
    //               END PROGRAM EXECUTION, BEGIN FUNCTIONS
    //====================================================================

    function getFiles(folder, subfolders, extensions) {
        // folder = folder object, not folder name.
        // subfolders = true to include subfolders.
        // extensions = string, extensions to include.
        // Combine multiple extensions with RegExp OR i.e. jpg|psd|tif
        // extensions case-insensitive.
        // extensions undefined = any.
        // Ignores hidden files and folders.
        var f;
        var files;
        var i;
        var pattern;
        var results = [];
        if (extensions) {
            pattern = new RegExp("\." + extensions + "$", "i");
        } else {
            // Any extension.
            pattern = new RegExp(".*");
        }
        files = folder.getFiles();
        for (i = 0; i < files.length; i++) {
            f = files[i];
            if (!f.hidden) {
                if (f instanceof Folder && subfolders) {
                    // Recursive (function calls itself).
                    results = results.concat(getFiles(f, subfolders, extensions));
                } else if (f instanceof File && pattern.test(f.name)) {
                    results.push(f);
                }
            }
        }
        return results;
    }

    function process() {
        var files;
        var i;
        // Ignore messages when opening documents.
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
        // Get PDF Preset to use.
        pdfPreset = app.pdfExportPresets.item(listPdfPreset.selection.text);
        format = listFormat.selection.index;
        extension = extensions[format];
        progress.display("Reading folder...");
        try {
            files = getFiles(folderInput, cbSubfolders.value, "indd");
            if (!files.length) {
                doneMessage = "No files found in selected folder";
                return;
            }
            progress.set(files.length);
            // Loop through files array.
            for (i = 0; i < files.length; i++) {
                progress.increment();
                progress.display(File.decode(files[i].name));
                processFile(files[i]);
            }
        } finally {
            // Restore PDF export preferences to all pages.
            // (must set twice, once text another enumerated value).
            app.pdfExportPreferences.pageRange = "All Pages";
            app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
        }
    }

    function processFile(file) {
        var baseName;
        var doc;
        var f;
        var fileOutput;
        var fullPath;
        var i;
        var link;
        var nameOutput;
        var pathOutput;
        var subpath;
        var textFrame;
        doc = app.open(file);
        try {
            if (cbUpdateSave.value) {
                for (i = 0; i < doc.links.length; i++) {
                    link = doc.links[i];
                    if (link.status == LinkStatus.LINK_OUT_OF_DATE) {
                        link.update();
                    }
                }
                // Make new file object to save converted docs.
                fileOutput = new File(doc.filePath + "/" + doc.name);
                doc.save(fileOutput);
            }
            // Set output path.
            subpath = Folder.decode(file.path).replace(Folder.decode(folderInput.fullName), "");
            baseName = file.name.replace(/\.[^\.]*$/, "");
            pathOutput = folderOutput.fullName;
            if (subpath) {
                pathOutput += subpath;
            }
            f = new Folder(pathOutput);
            if (!f.exists) {
                f.create();
            }
            // Add extension and build full path.
            nameOutput = baseName + inpSuffix.text + "." + extension;
            fullPath = pathOutput + "/" + nameOutput;
            fileOutput = new File(fullPath);
            switch (format) {
                case 0:
                    // ICML
                    app.incopyExportOptions.includeGraphicProxies = cbGraphicProxiesIcml.value;
                    app.incopyExportOptions.includeAllResources = cbAllResourcesIcml.value;
                    for (i = 0; i < doc.textFrames.length; i++) {
                        textFrame = doc.textFrames[i];
                        if (!textFrame.previousTextFrame) {
                            nameOutput = baseName + inpSuffix.text + i + "." + extension;
                            fullPath = pathOutput + "/" + nameOutput;
                            fileOutput = new File(fullPath);
                            textFrame.exportFile(ExportFormat.INCOPY_MARKUP, fileOutput);
                        }
                    }
                    break;
                case 1:
                    // IDML
                    doc.exportFile(ExportFormat.INDESIGN_MARKUP, fileOutput);
                    break;
                case 2:
                    // JPG
                    app.jpegExportPreferences.antiAlias = true;
                    app.jpegExportPreferences.embedColorProfile = cbEmbedProfile.value;
                    app.jpegExportPreferences.exportingSpread = cbSpreads.value;
                    app.jpegExportPreferences.exportResolution = parseInt(inpResolutionJpg.text, 10) || 72;
                    // ^ valid range 1-2400
                    app.jpegExportPreferences.jpegColorSpace = colorSpaceEnumsJpg[listColorSpaceJpg.selection.index];
                    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_ALL;
                    app.jpegExportPreferences.jpegQuality = qualityEnumsJpg[listQualityJpg.selection.index];
                    app.jpegExportPreferences.jpegRenderingStyle = JPEGOptionsFormat.BASELINE_ENCODING;
                    app.jpegExportPreferences.useDocumentBleeds = cbBleedJpg.value;
                    doc.exportFile(ExportFormat.JPG, fileOutput);
                    break;
                case 3:
                    // PDF (interactive)
                    try {
                        app.interactivePDFExportPreferences.exportAsSinglePages = false;
                    } catch (_) {
                        // Feature not present in older versions; ignore.
                    }
                    try {
                        app.interactivePDFExportPreferences.pdfDisplayTitle = PdfDisplayTitleOptions.DISPLAY_FILE_NAME;
                    } catch (_) {
                        // Feature not present in older versions; ignore.
                    }
                    app.interactivePDFExportPreferences.exportLayers = cbLayersPDFInteractive.value;
                    app.interactivePDFExportPreferences.exportReaderSpreads = cbSpreads.value;
                    app.interactivePDFExportPreferences.flipPages = false;
                    app.interactivePDFExportPreferences.flipPagesSpeed = 5;
                    app.interactivePDFExportPreferences.generateThumbnails = true;
                    app.interactivePDFExportPreferences.includeStructure = cbTaggedPDFInteractive.value;
                    app.interactivePDFExportPreferences.interactivePDFInteractiveElementsOption = InteractivePDFInteractiveElementsOptions.INCLUDE_ALL_MEDIA;
                    app.interactivePDFExportPreferences.openInFullScreen = false;
                    app.interactivePDFExportPreferences.pageRange = PageRange.ALL_PAGES;
                    app.interactivePDFExportPreferences.pageTransitionOverride = PageTransitionOverrideOptions.FROM_DOCUMENT;
                    app.interactivePDFExportPreferences.pdfJPEGQuality = qualityEnumsPdf[listQualityPDFInteractive.selection.index];
                    app.interactivePDFExportPreferences.pdfMagnification = PdfMagnificationOptions.DEFAULT_VALUE;
                    app.interactivePDFExportPreferences.pdfPageLayout = PageLayoutOptions.DEFAULT_VALUE;
                    app.interactivePDFExportPreferences.pdfRasterCompression = PDFRasterCompressionOptions.JPEG_COMPRESSION;
                    app.interactivePDFExportPreferences.rasterResolution = parseInt(inpResolutionPDFInteractive.text, 10) || 144;
                    // ^ valid range 72-300
                    app.interactivePDFExportPreferences.usePDFStructureForTabOrder = false;
                    app.interactivePDFExportPreferences.viewPDF = false;
                    doc.exportFile(ExportFormat.INTERACTIVE_PDF, fileOutput);
                    break;
                case 4:
                    // PDF (print)
                    app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
                    app.pdfExportPreferences.viewPDF = false;
                    doc.exportFile(ExportFormat.PDF_TYPE, fileOutput, false, pdfPreset);
                    break;
                case 5:
                    // PNG
                    app.pngExportPreferences.antiAlias = true;
                    app.pngExportPreferences.exportingSpread = cbSpreads.value;
                    app.pngExportPreferences.exportResolution = parseInt(inpResolutionPng.text, 10) || 72;
                    // ^ valid range 1-2400
                    app.pngExportPreferences.pngColorSpace = colorSpaceEnumsPng[listColorSpacePng.selection.index];
                    app.pngExportPreferences.pngExportRange = PNGExportRangeEnum.EXPORT_ALL;
                    app.pngExportPreferences.pngQuality = qualityEnumsPng[listQualityPng.selection.index];
                    app.pngExportPreferences.transparentBackground = cbTransparentPng.value;
                    app.pngExportPreferences.useDocumentBleeds = cbBleedPng.value;
                    doc.exportFile(ExportFormat.PNG_FORMAT, fileOutput);
                    break;
            }
        } finally {
            doc.close(SaveOptions.NO);
        }
    }

})();
Help me keep making new scripts by supporting my work. Click the PayPal button to contribute any amount you choose. Thank you. William Campbell
Download
Batch Export

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

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.

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 software products are the purchase of a non-exclusive license to use the software product and do not grant the purchaser any degree of ownership of the software code. Author of the intellectual property and copyright holder William Campbell retains 100% ownership of all code used in all software products regardless of the inspiration for the software product design or functionality.