Skip to main content
November 5, 2009
Question

Does anyone have a script to duplicate multiple pages in CS4?

  • November 5, 2009
  • 1 reply
  • 3526 views

I know it can be done, but I'm not a programmer. What would be the script to duplicate a user defined number of pages after a user defined page in a mulit-page InDesign document? We have documents with up to 159 pages, but need to have pages within the documents duplicated right after a selected page, not to the end of the document.

This is all I have of a script for this and I don't know how to make it work or make it user-interactive for page number input:

--Duplicating more than one page at a time in InDesign CS4
tell application "Adobe InDesign CS4"

    set mySourcePageNumber to UserInput1
    set numberOfPages to UserInput2
    tell application "InDesign 6.0.3"
        tell active document
            repeat numberOfPages times
                set myNewPage to duplicate page mySourcePageNumber
            end repeat
        end tell
    end tell
end tell

This topic has been closed for replies.

1 reply

Kasyan Servetsky
Legend
November 5, 2009

This is a very basic script, just written for you on CS3 and totally untested:

if (app.documents.length == 0){
    alert ("Please open a document, select an object, and try again.");
    exit();
}

var myDoc = app.activeDocument;
var myPage = myDoc.layoutWindows[0].activePage;
var myPageId = myPage.id;
var myDialog = app.dialogs.add({name:"Duplicate pages"});

with(myDialog.dialogColumns.add()){
    with(borderPanels.add()){
        staticTexts.add({staticLabel:"Duplicate front-most page # " + myPage.name});
        var myIntBox = integerEditboxes.add({editValue:1, smallNudge:1, largeNudge:10});
        staticTexts.add({staticLabel:" times"});
    }
}

var myResult = myDialog.show();

if(myResult == true){
    var myNumber = myIntBox.editValue;
    if (myNumber < 1) {
        alert(myNumber + " is invalid number.");
        exit();
    }

    for (i = 0; i < myNumber; i++) {
        myPage.duplicate(LocationOptions.AFTER, myDoc.pages.itemByID(myPageId));
    }
}

myDialog.destroy();

It duplicates the active (the front-most page) — its number you see in the bottom left corner of the document window. You can type a number or use up/down arrows to increment it by 1 (add shift key to increment it by 10).

Hope it helps.

Kasyan

November 5, 2009

Thank you for your response. Is this Javascript? ScriptEditor is tagging errors, so I'm assuming it's possibly not a complete script...(Please forgive me...my ignorance is showing here...)

Kasyan Servetsky
Legend
November 6, 2009

Yes, this is JavaScript — it should be saved as plain text file with jsx extension. Unzip the attached file and place it into Scripts Panel folder.

Kasyan