Skip to main content
Inspiring
February 9, 2022
Answered

Moving multiple pages via script

Is it possible to move mutliple pages in InDesign scripting with a single move call or do you need to move one page at a time?

m1b
m1bCorrect answer
Community Expert
February 9, 2022

It's hard to say if it's one page at a time. The move() method belongs to Page and not Pages, so you could infer that the API moves one page at a time. But here's a simple example of moving some pages, and it is basically one call for multiple pages if you do it this way.

- Mark

var doc = app.activeDocument;
var allPages = doc.pages;
var myPages = allPages.itemByRange(4, 7);
myPages.move(LocationOptions.AT_BEGINNING);

15 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
February 9, 2022

It's hard to say if it's one page at a time. The move() method belongs to Page and not Pages, so you could infer that the API moves one page at a time. But here's a simple example of moving some pages, and it is basically one call for multiple pages if you do it this way.

- Mark

var doc = app.activeDocument;
var allPages = doc.pages;
var myPages = allPages.itemByRange(4, 7);
myPages.move(LocationOptions.AT_BEGINNING);
Translate
JO_15Author
Inspiring
February 9, 2022

Interesting. I will need to give that a try! Thanks for sharing.

Translate
JO_15Author
Inspiring
February 9, 2022

Mark, 

 

It worked like a charm! Thank you so much for answering my question and helping out.

Translate
Community Expert
February 9, 2022

Seems it would be one page at a time. You can move using the move method, you can also look at the duplicate method.

https://www.indesignjs.de/extendscriptAPI/indesign-latest/index.html#Page.html#d1e203331__d1e204452

https://www.indesignjs.de/extendscriptAPI/indesign-latest/index.html#Page.html#d1e203331__d1e204318

-Manan

Translate
-Manan