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

Indesign script to insert new master on every other page

Community Beginner ,
May 02, 2025 May 02, 2025

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

 

Any help is appreciated. Thank you!!

TOPICS
Scripting
493
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
Adobe Employee ,
May 02, 2025 May 02, 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

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 Beginner ,
May 02, 2025 May 02, 2025

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

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 ,
May 02, 2025 May 02, 2025

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

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 ,
May 02, 2025 May 02, 2025

I don't think this will work since it's not injecting new pages. Try this instead: 

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;

}

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 Beginner ,
May 02, 2025 May 02, 2025

I used the text editor for mac but it doesn't work, changed the extension to .jsx or do i have to use another plain text editor

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 ,
May 02, 2025 May 02, 2025
quote

I used the text editor for mac but it doesn't work, changed the extension to .jsx or do i have to use another plain text editor

By @dsomrz

 

 

If you're using TextEdit, then make sure to use the plain text mode. Cmd-Shift-T toggles between plain text and RTF, you'll see right away which mode you're in.

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 Beginner ,
May 02, 2025 May 02, 2025

the first one is useful if i want to make everyother page a different master. The second one I get this error. see screen shot.

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 ,
May 02, 2025 May 02, 2025

Sorry the colon after ps.length should be a semicolon. Coding on phones is hard.

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 ,
May 03, 2025 May 03, 2025

Found a script here that seems to do it

https://community.adobe.com/t5/indesign-discussions/script-to-insert-new-master-on-every-other-page/...

 

Might be what's here already , haven't checked. 

 

 

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 Beginner ,
May 05, 2025 May 05, 2025

thanks. I saw that but when I click on the link it says safari can not open the page. I tried in Chrome and same thing.

 

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 Beginner ,
May 05, 2025 May 05, 2025

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;
}

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 ,
May 05, 2025 May 05, 2025

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;
}

 

 

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 Beginner ,
May 05, 2025 May 05, 2025
LATEST

AWESOME!. Thanks that work, really appreciate it. Have a good day

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 ,
May 02, 2025 May 02, 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.

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 Beginner ,
May 02, 2025 May 02, 2025

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

 

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 ,
May 02, 2025 May 02, 2025

What hinders you to change the setup to facing pages?

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 ,
May 02, 2025 May 02, 2025

Because they need the facing page to be blank?

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 Beginner ,
May 02, 2025 May 02, 2025

nothing hinders me from changing it to facing pages. I just want to be able to add a blank page after each page without having to change their file. I can do this in Acrobat, but wanted to know if there was a way to do it in Indesign

 

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 ,
May 02, 2025 May 02, 2025

THe correct way is to set up as facing pages. Inserting pages will also change the document. Set up the facing master, one side empty, the other with text frame and let the text run in.

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 Beginner ,
May 02, 2025 May 02, 2025

ok, it is a customer supplied indesign file.

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