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 .
“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.
Loic
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.
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…
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.
Petteri,
I wonder if that script doesn’t exist already ? I am picking infos about that.
Loic
Eugene, would you mind sending me your file so I can test on it ?
Thanks Loic! If you find some info, I´m more than happy to receive it….
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…
Hi Loic, I sent you a message via your Contact Me on your webpage.
Thanks
Eugene
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.
Loic
Yeah Eugene,
Well received and answered you back ;-)
Loic
This Loic is a champ, huh? :)
This looks terrific. I’ve been doing this the hard way, so this script is very welcome. Thanks!
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? ;-)
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.
How many more arms do you need, Loic? ;-)
Give me all that you have aside :-D
@Petteri Paananen
I updated my customExport script.
Now it can export any type of format.
https://www.scriptopedia.org/index.php?post/custompdfexport.jsx.html&navlang=en
Regards,
Loic
Great job Loic! Thanks… this will be very usefull.
Did you check out is it posible to make other way around? Make one SWF from multiple INDD?
Make one SWF from multiple INDD?
Nope. I will add this on my todo list ;-)
Bye,
Loic
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.
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?
Thanks.
Phil Frank
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
Hi Loic,
I sent you an email on your web site so you’d have my address. If you email me there I’ll send you the file.
Phil
Hi Phil,
Answered you back. Thanks a lot to you and Eugene for the test files.
Loic
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.
Any chance there’s a version for CS5?
Do you inform me about the last advances of this script?
Thank you,
Ilka
Loic,
Is there a way to modify this script to make it export all pages as individual indd files?
Thanks!
Andy
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.
Script is not working on CS5 :(
Try running Martinho DaGloria’s “Make It Run” metascript first:
https://automatication.com/index.php?id=20
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.
Scriptopedia site is down.
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?
Second that, Paul. I’m in the exact same situation as you are. Any help would be appreciated!
Anything like this available for PC ??
Stevie, Javascripts run on both Mac and Windows. Providing your version of ID is not too old, it should run just fine.
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.”
Very golod article! We will be linking to this great post on our website.
Keep up the good writing.
Seems the script has been updated at another location for CS6, if this helps : https://kasyan.ho.com.ua/extractpages.html (it seems to work under CC2014
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
I found this for CS6:
https://www.kasyan.ho.com.ua/extractpages.html
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.
Hey Michael,
I’d like to check it out.
Thanks for posting!
-Steve
Hey Mike, have you still got the script for splitting indesign files?
Really appreciate getting a copy of it, thanks
[email protected]
Really appreciate getting a copy of it, thanks
[email protected]
Hi Michael,
Is it possible for you to send me a copy of your script which splits long documents into smaller ones? You may send your file to: gregory dot mouning at yale dot edu.
Thanks!
I’d need an address to send to.
Michael
If you can send to [email protected], that would be great!
Actually, I forgot we changed that account, can you please send to [email protected]
Hello Michael,
I would also be interested in your script: [email protected]
Hi Michael,
Please send me the script as well.
Much appreciated.
[email protected]
Hi Michael,
could you send your modified script to [email protected]? Thanks very much!
Jens
Hi Michael,
Can I please get the script to [email protected]
Michael, if you could send me your script that would be greatly appreciated. [email protected]
Hi Michael
If you can send to [email protected], that would be great!
Hi Michael,
good job! I’d make good use of your script. Please send to [email protected].
Thanks!
Hi Michael,
I could really use your script as well. Could you please send it to me at [email protected] ?
Thank you for making it!
Ben
@Loic: am I correct in assuming that this line:
var exportdoc = doc.save(File(saveextractfolder + 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.
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.
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.
Enjoy!
—-
//—mini page extractor – original script by Loic, scriptopedia.org, 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){
app.activeDocument.pages[-1].remove();
}
//remove first page until only one is left – this is the correct page
while (app.activeDocument.pages.length>1){
app.activeDocument.pages[0].remove();
}
var exportdocname = app.activeDocument.name.replace (/\.indd$/, “”) + “_Pg” +(w) +”.indd”; //new name for the extracted document
var exportdoc = app.activeDocument.save(File(extractFolder +”/”+ exportdocname)); //save the extracted document in the extract folder with its new name
app.activeDocument.close(SaveOptions.no); //important to close the active document _without_ saving, as all pages but one were removed in the active document.
app.open(origdoc, true); //original document has to be opened again in order for the for-loop to continue.
}
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
Oops, some long text lines look like they got compressed. Can’t see any code option for Comments, if you want a more usable script for education, just holler.