Skip to main content
dsomrz
Known Participant
May 2, 2025
Answered

Indesign script to insert new master on every other page

  • May 2, 2025
  • 2 replies
  • 2294 views

I have an indesign document that I have to insert a blank or Master page everyother page. 

 

Any help is appreciated. Thank you!!

Correct answer brian_p_dts

thanks I still get an error

var d = app.activeDocument;
var ps = d.pages;
var i = ps.length;
while(i--) {
var p = d.pages.add(LocationOptions.AFTER, ps[i];
p.appliedMaster = null;
}


Ack, a missing paren too. More coffee before posting and not on mobile : ). This should do it. 

 

var d = app.activeDocument;
var ps = d.pages;
var i = ps.length;
while(i--) {
var p = d.pages.add(LocationOptions.AFTER, ps[i]);
p.appliedMaster = null;
}

 

 

2 replies

Willi Adelberger
Community Expert
Community Expert
May 2, 2025

Why do you want to do that? If you want to  print left and right, why do you not set up the document with facing pages? This would be the correct way.

dsomrz
dsomrzAuthor
Known Participant
May 2, 2025

it was a supplied Indesign document from a customer. I didn't set it up originally.

 

Willi Adelberger
Community Expert
Community Expert
May 2, 2025

What hinders you to change the setup to facing pages?

Anubhav M
Community Manager
Community Manager
May 2, 2025

Hello @dsomrz,

Can you try using the following script to see if it helps with your workflow:

// Create a new master spread
var myDocument = app.activeDocument;
var myMasterSpread = myDocument.masterSpreads.add();
var myMasterPage = myMasterSpread.pages.item(0);

// Loop through the pages and apply the master spread to every other page
for (var i = 1; i < myDocument.pages.length; i += 2) {
    myDocument.pages.item(i).appliedMaster = myMasterSpread;
}


Looking forward to hearing from you.

Anubhav

dsomrz
dsomrzAuthor
Known Participant
May 2, 2025

would i copy and paste into script editor or text edit.

brian_p_dts
Community Expert
Community Expert
May 2, 2025

Use a plain text editor (not RTF), save as .jsx file then save jsx to script folder in panel.