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

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

Contributor ,
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

208

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

Advisor , 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

Votes

Translate

Translate
Advisor ,
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

Votes

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

Copy link to clipboard

Copied

LATEST

Worked like a dream! Thank you!

Votes

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