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

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

Guest
Nov 05, 2009 Nov 05, 2009

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

TOPICS
Scripting
3.6K
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
Valorous Hero ,
Nov 05, 2009 Nov 05, 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

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
Guest
Nov 05, 2009 Nov 05, 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...)

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
Valorous Hero ,
Nov 06, 2009 Nov 06, 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

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
Guest
Nov 06, 2009 Nov 06, 2009

Thanks. I found my old "CreaText" program and was able to save it out as a javascript file. It works great! I'll work on tweaking it this weekend and see if I can get it to do the rest of what I need. Thank you so much for getting me pointed in the right direction!!!

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
Valorous Hero ,
Nov 06, 2009 Nov 06, 2009

You can use ExtendScript Toolkit to edit javascripts — it's preinstalled with InDesign. Check out your Applications/Utilites/Adobe Utilites/ExtendScript Toolkit CS4 folder.

Kasyan

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
Guest
Nov 06, 2009 Nov 06, 2009

Thank you. I can't do much here at work (where the script is needed) because the IT department has locked down the program areas. But I'll try it at home.

Do you have a good place to get more information on a non-programmer's guide to javascript? I can see what you did and understand it, but I can't seem to do what needs to be done by myself...and I want to learn how.

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
Valorous Hero ,
Nov 06, 2009 Nov 06, 2009

I recommend you to start from here: http://www.adobe.com/products/indesign/scripting/?promoid=DRHXE

Under Scripting resources section you will find Adobe Introduction to Scripting and Adobe InDesign CS4 Scripting Tutorial.

Kasyan

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
Guest
Nov 06, 2009 Nov 06, 2009

Thanks! I'll check it out! I appreciate your help.

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
Explorer ,
Mar 30, 2016 Mar 30, 2016
LATEST

Dear Kasyan ,

can i use your code to duplicate the whole pages or the main document with reversed order

Thanks in advance

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