Thanks for coming to, the world's #1 resource for all things InDesign!

Free Script Splits Long InDesign Files into Smaller Ones

Sandee Cohen alerted me and a few other lucky souls this morning to a useful, free script called ExtractPages she recently came across.

The script provides two features that InDesign’s Move Pages command (Layout > Pages > Move Pages) lacks: First, it can quickly spit out  a series of single-page INDD files from the page range you enter, just like the Extract Pages command in Adobe Acrobat. Just turn on the appropriate checkbox in the script’s simple dialog box:

Second, the script can create new InDesign files on the fly from the pages you extract – InDesign’s Move Pages command can only move or copy pages from one InDesign doc to another one, not to a new one.

So, ExtractPages is handy script to have if, say, you’ve got a long multi-chapter book in a single InDesign document that you want to quickly split into multiple InDesign files, one document per chapter. This is something you need to do if you want to export a book to ePub and have the chapters start on their own pages, for example.

It’s possible to use Move Pages to do this manually (just set up a starter InDesign file for each chapter beforehand), but that means you have to laboriously match page dimensions and other attributes, and then remember to delete the additional, superfluous starter page in each of those files afterwards. You don’t need to bother with that if you use the script.

ExtractPages has one weirdness that can throw you: Not only doesn’t it automatically open the new INDD file(s) it creates, it closes the source document as soon as you run the script. If there were unsaved changes, they’re gone.  (This happened to me during testing on a Mac w/CS4, your mileage may vary.) So if you want to use it, be sure to save your source document first, at least until the script’s author fixes it.

Download ExtractPages script from its Scriptopedia page or directly by clicking here .

Anne-Marie Concepcion

Anne-Marie Concepcion

Anne-Marie “Her Geekness” Concepción is the co-founder (with David Blatner) and CEO of Creative Publishing Network, which produces InDesignSecrets, InDesign Magazine, and other resources for creative professionals. Through her cross-media design studio, Seneca Design & Training, Anne-Marie develops ebooks and trains and consults with companies who want to master the tools and workflows of digital publishing. She has authored over 20 courses on on these topics and others. Keep up with Anne-Marie by subscribing to her ezine, HerGeekness Gazette, and contact her by email at or on Twitter @amarie
Anne-Marie Concepcion

Latest posts by Anne-Marie Concepcion (see all)

  • - November 30, -0001
Related Articles

63 Comments on “Free Script Splits Long InDesign Files into Smaller Ones

  1. “at least until the script?s author fixes it.”

    Well, some work to do :-)

    Ps: I have to admit that Laurent Tournier pointed me another bug that I didn’t have time yet to fix.
    The script works very fine with standalone documents but not so efficiently with books.
    This article is an occasion to me to fix both issues :-)

    Thanks a lot for your article I am very honoured.
    BTW, if anyone else has a wish, that’s the moment.


  2. Just tried it on a document that had facing pages and connected text frames.

    It also had running headers on master pages, but manually inserted running heads too (Months being inserted which couldn’t be done automatically)

    Text isn’t removed from the text frame, so every document (24 documents) have an overflowing text frame.

    Some running heads started overlapping the manually inserted running heads.

    Anchored images went wonky and appeared on some pages in the wrong place (overlapping text).

    The script is good, and it’s great that it does what it does. But there’s definitely of cleaning up to be done afterward.

  3. That´s a nice one, but I actually would need a script that would do vice versa; combine multiple documents to one indd.

    Those documents contains usually only one spread (with 2 pages)… I know that it´s possible to do with Move Pages feature, but it would be super cool to have a script for that…

  4. Ok, I am going to start fixing the problem Anne-Marie pointed out and will work on a new version with the improvements Eugene talked about.

    I wonder if that script doesn’t exist already ? I am picking infos about that.

  5. Loic, I saw that you have done a script called custompdfexport.jsx… what do you think, would it be hard to change to export SWF instead of PDF?

    I actually asked a combining script because I would like to export multiple indesign documents to SWF and now I have to combine them first manually to one indd…

  6. God, give me four more arms !!!

    Petteri, I was asked on an other side to do so.
    Then the answer is, I am on it.

    I will try to release that asap.


  7. Eugene: I tried the same thing with the threaded frames, and saw what you saw. I think the script is still useful as is for when you’re breaking a long doc along “natural” fault lines ;-) like in between wholly-contained chapter threads. Didn’t think to test anchored objects … hmmm.

    Would be cool to integrate the Break Frames script with this one. So that when the user enters a page number in the ExtractPages dialog, the script runs the break frames routine, if/as necessary, at the page numbers entered.

    How many more arms do you need, Loic? ;-)

  8. Anne-Marie: I was thinking the same thing, the script runs the Break script first then goes about it’s business. Of course would need this to be non-destructive to the document I am splitting up.

    I’ve sent Loic a file that isn’t neat at all in terms of layout, i.e., I took a few shortcuts due to time contraints and just plonked text frames on pages, but I’ll never need this layout again and if I do I can probably fix it up so it works better.

    The problem is when you have loose text frames and running heads that are aligned away from the spine. As that’s how I set them up, no point in two styles for left and right pages anymore.

    Yet the script would put some left pages on right pages, as it’s a new document, and 1 being a right page.

    So loose text frames and running heads go askew.

    And that’s why I choose that file to run the script on because I knew it was setup incorrectly, and that’s how I imagine a lot of people set up files when they’re in a hurry.

    The script needs to cater to everyone of all skill levels lol :D

    Well that’s just what I think. Of course if I’d setup the document correctly it probably wouldn’t be an issue.

    I have an even more complicated document that goes completely haywire when I add or delete a page, as some items are anchored, some are not and it’s just completely bezerk.

    The script is definitely great, and if I needed to move chapter by chapter out of a document this would be the ticket as long as you incorporate the entire story in the page selection.

    Currently though when I try to extract all pages as single documents it keeps the text and anchored objects. So the Break script running first would sort that out.

  9. Thanks, that would be very helpful script. I have lot´s of cases where my publication is in small peaces. Like one spread in one indd-file.

    Now I have to combine them manually before I can export my SWF.

    If you do that script, I could give you a free license of eDocker for change. For creating user functions for SWF files.

  10. I’m afraid for me this script isn’t really doing anything. It does generate a new document, but the new document has all the pages in it that the old one has. It wipes out all but one or two of the pages, but the text is still all there when I insert a new page and reflow the text. And when I told it to extract page 3 and then remove it after extraction, it saved the file with the new name, but when I opened it, I was back to page 1 and all the rest of the text was still there. This is a 36-page piece of a larger document in which all the text is a single text flow.

    Perhaps I’m doing something wrong?


    Phil Frank

  11. Hi Phil,
    I was told some things were not optimal but your case is very problematic.
    Do you mind sending me your file so I can test it at home.
    I am working on a new version that should fix all the problems and your file may help in that goal.

    TIA Loic

  12. I have to say, I’ve been searching for a script like this for quite sometime and it’s been a godsend to me while working on a rather complex document.

    One thing I have found with the script is that the page numbers it uses aren’t exactly correct. It seems to use the number of the page itself in the context of the first page, as opposed to the document’s page numbers.

    For example: Assuming the first three pages of your document were numbered using roman numerals (I, II, III), then pages started from 1 onwards.

    Now say you want to export pages 13-18. Logically you would expect to type in 13-18 in the export dialogue, but this will actually give you pages 10-15 of the document.

    The reason is that the roman numerals or non-standard page numbers are being treated as pages.

    None the less, great work and just remembering some simple checking before exporting overcomes the above problem.

  13. Hi,
    I have a document where there are several section breaks with a new pagination, and I get an error at line 291. I think this is due to the script looking for the absolute page numbers vs. the named page numbers (I only use applescript so the approximate is the property called “name” for each page.

    Ah, well. Thanks anyway.

  14. This gets me every time – I always forget – threaded stories on multiple pages give me problems. If you are extracting pages with this script and getting wrong pages or only pages starting from beginning – then you probably have threaded stories across page boundaries. There is an Adobe supplied script called “Split Story” that can split your story and then this script works fabulously.

  15. I am getting the following error when I run the script:
    ReferenceError: App.local.toLocaleName is not a function

    I updated the script with “make it run” already. I am trying to run the script on a 48 page document with facing pages in CS6. Any help would be greatly appreciated.

    If I can’t get the script to run, does anyone have a suggestion on a work-around? My assumption is that I will have to create 48 new documents, placing a single page in each document. Does that sound right?

    • I know this is an older thread, but i’m having this same problem (the Javascript error of “ReferenceError: App.local.toLocaleName is not a function”). did you ever get a resolution to this?

  16. Why am I getting this? I’m following directions. [in Windows 7. InDesign CS5. Trying to run it on extractpages. jsx – hadn’t run this file before. Trying to update it to CS5 to extract pages for fixed EPUB. It makes a new file but gives me this error:] “Error. No file is associated with current script.”

  17. Hi guys

    Can any one helpe out?

    I’m searching for a indesign script that will split a multi page indd into single SPREAD indd, like so :
    001.indd and then 002-003.indd, 004-005.indd, 006-007.indd, …….. 036.indd
    Ofcourse the first and last page cannot be spreads…

    Can anyone help me out ????
    Thanks in advance

  18. This script is great, but what would be really helpful is if you could extract multiple sets at one time. Such as 1-13, 14-18, 19-24…all in one extract instead of having to perform the same extract on one document multiple times. Has anyone made this adjustment to the script?

    • I have a script that works on ranges of pages/spreads. It can save them as separate documents and create a book out of them as well. It has an interface where you can actually select the pages you want to save out separately. It also can split document based on paragraph styles. If interested, let me know. I’d be glad to send it to you.

  19. @Loic: am I correct in assuming that this line:

    var exportdoc = + exportdocname));

    is the one doing the heavy lifting?
    I am trying to understand how the script works, but I can’t see where the choice is made as to what page gets exported as a new document – I tried putting up an alert just after this line, and yes, it creates a one page document if the “separate” was checked, before the “separate sub function, which only opens the original document again as far as I can tell.

    This line is inside a for-loop with the same length as the amount of pages chosen in the dialog. If it is this one line, I find it to be a genius solution. I just don’t understand how it works… The “save” command is ExtendScript, but then you use a core javascript File function.

  20. Oh. I had missed the page removal loops earlier. Was confused by the nesting. I see it now. If I make it work (next week) I’ll be back here.

  21. Alright, I got it working now. The basic workings of the script are so simple and it only uses standard page removing and file saving commands, which makes it both flexible, and a perfect contender for educating purposes. Thanks for providing us with them, Loic and Peter Kahrel.

    So, I wanted to understand what this script was doing and finally took the time to write a mini version. This is it. Maybe someone learning ExtendScript might find it useful.

    Note: it has no dialog box, it assumes that you know what you are doing, that you have only one open document, and that you always work on a copy of your precious original document, in a separate folder. It is for educational purposes and there is _no error handling or version control_, if you want that you should probably use the original script, ask Loic for a version for you, or add your own.

    This mini version always separates every page as a new document (this is what I wanted) and it iterates through all pages in the original. I use app.activeDocument a lot here, mostly since it makes the script a little easier to read and to understand what is happening. Changed the page removal for-loops to while-loops, I found it easier to visualise with them in this case.

    //—mini page extractor – original script by Loic,, modded by zixk2. Only for education, use at your own risk — //
    //— and have fun! —//
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

    extractFolder=Folder(app.activeDocument.filePath + “/extracted/”);
    if (!extractFolder.exists){extractFolder.create();}

    var origdoc = new File (app.activeDocument.fullName);
    for(w=0; ww+1){
    //remove first page until only one is left – this is the correct page
    while (app.activeDocument.pages.length>1){
    var exportdocname = (/\.indd$/, “”) + “_Pg” +(w) +”.indd”; //new name for the extracted document
    var exportdoc = +”/”+ exportdocname)); //save the extracted document in the extract folder with its new name
    app.activeDocument.close(; //important to close the active document _without_ saving, as all pages but one were removed in the active document., true); //original document has to be opened again in order for the for-loop to continue.

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

Leave a Reply

Your email address will not be published. Required fields are marked *