Skip to main content
Inspiring
February 9, 2022
Answered

Moving multiple pages via script

  • February 9, 2022
  • 2 replies
  • 1894 views

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?

Correct answer m1b

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

2 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);
Community Expert
February 9, 2022

Hi Mark,

Good one, I missed that. However, correct me if I am wrong this will always move a contigous set of pages to a common destination, it won't cater to use cases of moving say single pages to different locations.

-Manan

-Manan
Joel Cherney
Community Expert
Community Expert
May 16, 2025

Hi Mark,

Sorry to open an old thread. I'm surprised how hard it is to find a script that basically does Move Pages to another document. I have 10 lessons per book, 10 separate ID files,  and need to combine them and I'm doing it manually. 

Do you happen to have a script you can share that would facilitate this? (I have used scripts but know nothing about writing them).  I know I have to have the source file open to move to the target file manually. In my fantasy, I would have the target file open and a script would ask me to choose the source file(s). Or just combine all. But anything would be better than what I'm doing now.

MultiFileImporter places an image of a page, not threaded pages.
MergeFiles-2016 script doesn't seem to handle text threads.

Thanks for any advice!

-Carol

 


I don't know what Mark has up his sleeve, but I have this little snippet of code that I modified, years ago, based off an ancient Marijan Tompa post. I might be able to modify it to suit your purposes, as I wrote (er, stole) it at a time where I really didn't have the skill to modify it easily. The way it's currently set up is that it copies all of the pages from the active document into the next open document, after the last page. It doesn't move the pages, it duplicates them, so it's more of a "copy pages" script than a "move pages" script. If that doesn't work for you, I think all you'd have to do is change ".duplicate" to ".move". 

var pageSource = app.documents[0]; 
pageSource.pages.everyItem().duplicate(LocationOptions.AFTER, app.documents[1].pages.item(-1));

 

Community Expert
February 9, 2022