Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Possible Script to quickly rearrange InDesign pages based on page size?

Community Beginner ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

I have a multiple page InDesign document I've merged together, I'm looking for a quick way to rearrange the pages either based on the page size or master page assigned. Is there a script I could use to accomplish this? 

TOPICS
How to, Scripting

Views

71

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

Advocate , Sep 09, 2021 Sep 09, 2021
Hello @LynxKx, Give the below code snippet a try to rearrange the pages based on the applied Master page.var doc = app.documents[0]; for (p = doc.pages.length-1; p >= 0; p--) { for (i = doc.pages.length-1; i >= 0; i--) { if (doc.pages[p].appliedMaster.name == doc.pages[i].appliedMaster.name){ doc.pages[i].move(LocationOptions.AFTER,doc.pages[p]); } } }Regards,Mike

Likes

Translate

Translate
Advocate ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

Hello @LynxKx,

 

Give the below code snippet a try to rearrange the pages based on the applied Master page.

var doc = app.documents[0];

for (p = doc.pages.length-1; p >= 0; p--) {
  for (i = doc.pages.length-1; i >= 0; i--) { 
    if (doc.pages[p].appliedMaster.name == doc.pages[i].appliedMaster.name){

 doc.pages[i].move(LocationOptions.AFTER,doc.pages[p]);

     }
  }
}

Regards,

Mike

Likes

Translate

Translate

Report

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 ,
Sep 09, 2021 Sep 09, 2021

Copy link to clipboard

Copied

LATEST

Worked like a dream! Thank you!

Likes

Translate

Translate

Report

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