Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

InDesign Books

New Here ,
Nov 26, 2025 Nov 26, 2025

We are working on multiple InDesign books for 5 different contracts, within each contract there are approximately 80 docs in a book. Is there a solution to update all the "Prefix Section Makers" within the Numbering & Section Options panel. I have a Section maker on the master pages, placed the Section Marker in the Numbering & Section options panel, checked "Include Prefix when Numbering Pages."

 

In the book sync menu, there is an option to change the document numbering options, but you can only change one document at a time in a book.

 

Is there a workaround?

TOPICS
Bug , Experiment , Scripting , Sync and storage
117
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2025 Nov 27, 2025

There are ways to run a script against all documents in a book. But where do the section marker and the section prefix come from? How would you know the values of the prefix and the marker for each document?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 28, 2025 Nov 28, 2025
LATEST

@rebecca_7310 I have written a script that may help. (Or may not, because we don't understand your situation very well yet.)

 

The script performs a basic find/change operation on every section prefix in every open document. If it seems useful, give it a try.

- Mark

 

Screenshot 2025-11-29 at 14.22.43.png

/**
 * @file Find Change Section Prefixes.js
 *
 * Perform a find/change of section prefixes in all open documents.
 *
 * @author m1b
 * @version 2025-11-29
 * @discussion https://community.adobe.com/t5/indesign-discussions/indesign-books/m-p/15610033/thread-id/643194
 */
function main() {

    var settings = {
        findWhat: 'A',
        changeTo: 'B',
        showResults: true,
        showUI: true,
        previewFunction: getChangeCount,
    };

    if (0 === app.documents.length)
        return alert('Please open a document and try again.');

    var docs = app.documents;

    // collect all the sections
    var prefixes = [];
    var sectionPrefixes = {};

    for (var i = 0; i < docs.length; i++) {

        for (var j = 0; j < docs[i].sections.length; j++) {

            var section = docs[i].sections[j];

            if (!sectionPrefixes[section.sectionPrefix]) {
                sectionPrefixes[section.sectionPrefix] = [];
                prefixes.push(section.sectionPrefix);
            }

            sectionPrefixes[section.sectionPrefix].push({ doc: docs[i], index: section.index });

        }

    }

    if (
        settings.showUI
        && 2 === ui(settings)
    )
        // user cancelled
        return;

    // perform the find/change
    var changeCount = findChangeSectionPrefixes();

    if (settings.showResults)
        alert('Changed ' + changeCount + ' section prefixes.');

    /** Returns the find count, without performing the change. */
    function getChangeCount() {
        // run the find/change, but preview only
        return findChangeSectionPrefixes(true);
    };

    /**
     * Performs the find/change (or just the find, if `countOnly`).
     * Note this is not a stand-alone function, it requires the
     * `prefixes` and `sectionPrefixes` objects.
     * @author m1b
     * @version 2025-11-29
     * @param {Boolean} countOnly - whether you just want the find count, without performing the change (default: false).
     * @returns {Number} - the number of instances found/changed.
     */
    function findChangeSectionPrefixes(countOnly) {

        var counter = 0;

        var method = settings.findWhat instanceof RegExp ? 'search' : 'indexOf';

        for (var i = 0, p; i < prefixes.length; i++) {

            p = prefixes[i];

            if (-1 === p[method](settings.findWhat))
                continue;

            samePrefixLoop:
            for (var j = 0; j < sectionPrefixes[p].length; j++, counter++) {

                if (countOnly)
                    continue samePrefixLoop;

                var s = sectionPrefixes[p][j];
                s.doc.sections.item(s.index).sectionPrefix = p.replace(settings.findWhat, settings.changeTo);

            }

        }

        return counter;

    };

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Find/Change Section Prefixes');

/**
 * UI.
 * @author m1b
 * @version 2025-11-29
 * @param {Object} settings - the settings for this script.
 * @returns {1|2} - ScriptUI result code (1 = go ahead, 2 = user cancelled).
 */
function ui(settings) {

    var previewCount = 0;

    var w = new Window("dialog", 'Find/Change Section Prefixes');
    var wrapper = w.add('Group {orientation:"column", alignment:["fill","fill"], margins:[10,10,10,10], spacing: 20 }');

    var findGroup = wrapper.add('Group {orientation:"column", alignment:["fill","top"] }');
    var findLabel = findGroup.add('StaticText {text:"Find:", preferredSize:[450,-1], alignment:["left","top"], justify:["left","top"]}');
    var findField = findGroup.add('EditText {text:"A", preferredSize:[450,-1], alignment:["left","top"], justify:["left","top"]}');

    var changeGroup = wrapper.add('Group {orientation:"column", alignment:["fill","top"] }');
    var changeLabel = changeGroup.add('StaticText {text:"Change:", preferredSize:[450,-1], alignment:["left","top"], justify:["left","top"]}');
    var changeField = changeGroup.add('EditText {text:"B", preferredSize:[450,-1], alignment:["left","top"], justify:["left","top"]}');

    var previewText = wrapper.add('StaticText {text:"", preferredSize:[450,-1], alignment:["fill","top"], justify:"right" }');

    var bottomUI = wrapper.add('Group {orientation:"row", alignment:["fill","top"], margins:[0,20,0,0] }');
    var checkboxes = bottomUI.add('Group {orientation:"column", alignment:["fill","fill"], alignChildren:["left", "top"], margins:[0,8,0,0] }');
    var useRegExpCheckbox = checkboxes.add('CheckBox { text:"Use regular expression" }');
    var buttons = bottomUI.add('Group {orientation:"row", alignment:["right","top"], alignChildren:["right","top"] }');
    var cancelButton = buttons.add('Button {text:"Cancel", properties:{ name:"cancel" } }');
    var okButton = buttons.add('Button {text:"Find/Change", properties:{ name:"ok" } }');

    // enforces a hierarchy between remove sections and combine spreads at joins
    useRegExpCheckbox.onClick = updateUI;

    findField.onChanging = function () {
        previewText.text = '';
        updateUI();
    };

    changeField.onChange = function () {
        settings.changeTo = changeField.text;
    };

    okButton.onClick = function () {
        updateUI();
        w.close(1);
    };

    updateUI();

    w.center();
    return w.show();

    function updateUI() {

        if (!findField.text)
            return;

        try {
            if (useRegExpCheckbox.value)
                settings.findWhat = new RegExp(findField.text);
            else
                settings.findWhat = findField.text;

            previewCount = settings.previewFunction();

            previewText.text = 'Will find ' + previewCount + ' instances.';

        }

        catch (error) {
            previewText.text = 'Not a valid regular expression.';
            previewCount = 0;
        }

        finally {
            okButton.enabled = previewCount > 0;
        }

    };

};
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines