Sort parent pages by prefix

The only way to sort parent pages in the Pages panel is to drag them up and down. This is finicky: you need a steady hand. It's easy accidentally to apply the parent spread you're moving to another spread because the panel's tolerance is near zero. That's on Windows; on the Mac it's even worse, apparently.

This is something you can probably live with (reluctantly) if your document has only a small handful of parent spreads. But if the document contains a lot of masters or if you have a lot of documents to process, then it's more convenient to use the script described below.

To use the script, open a document and run the script from InDesign's Scripts panel. It has no interface. When the script is done you see a copy of the document in a new tab with -fixed added to its name (so ch01.indd is copied to ch01-fixed.indd).

The original document was not touched: the script exported the document to IDML, ordered the master spread in there, renamed the IDML, and opened it.

That's essentially all there's to it. If you're not interested in the technical backround you needn't read further – just download the script (link at the bottom of the page), install it, and use it.

Background

An IDML file is a zip archive with IDML for its file type rather than ZIP. (EPUB and DOCX files, too, are zip archives with a different name for their file type.) You can edit such files directly with some applications; Oxygen is an example. Another possibility is 7ZIP, a free zip utility; it can open any zip file directly, and you can then use an editor of your choice to edit any of the files in the archive.

If you don't have any of these programs you'll have to unzip the archive. Probably you'll have to change the archive's type to ZIP. After unzipping the file you'll see the archive's folder structure:

Structure of an IDML file

The file you're after is designmap.xml. It contains a section that lists the parent spreads in the order that they appear in the InDesign document:

<idPkg:MasterSpread src="MasterSpreads/MasterSpread_ue4.xml"/>
<idPkg:MasterSpread src="MasterSpreads/MasterSpread_ueb.xml"/>
<idPkg:MasterSpread src="MasterSpreads/MasterSpread_ud5.xml"/>
<idPkg:MasterSpread src="MasterSpreads/MasterSpread_uf2.xml"/>

The problem, of course, is that these names don't mean anything to you: they use some internal reference rather than the names that you see in InDesign.

(The term 'master spread' was changed to 'parent spread' some years ago, but because IDML uses script terminology and because the script term 'master spread' couldn't be changed, you still see the term 'master spread' in IDML files -- and in scripts, too.)

So now you first have to go and find a file that tells you which InDesign names correspond with the names in designmap.xml. Go to the MasterSpreads folder, where you'll see the XML files listed in designmap.xml. Open MasterSpread_ue4.xml in a text editor; you'll see something like the following line (some irelevant details omitted):

<MasterSpread Self="ue4" ... Name="A-Parent" NamePrefix="A" BaseName="Parent" ...

This tells you that the file name MasterSpread_ue4.xml corresponds to the parent spread A-Parent. Make a note of all the correspondences, then go back to designmap.xml and re-order the block of master spread references using your correspondence list.

Save the designmap.xml file. If you had to unzip the archive, zip it and change the file type from ZIP to IDML, and change the name to something else (such as adding -fixed) to preserve the original document. When you open the IDML file in InDesign you'll see that the order of the parent spreads is as you changed it in the IDML.

The script does all this. When you run it with a file manager open you might just see that the IDML is saved, unpacked, changed, repacked, and removed.


Version history

20 Aug. 2024: Fixed a bug that prevented the IDML to be opened on the Mac.

14 Aug. 2024: Posted.


Useful script? Saved you lots of time?

Consider making a donation. To make a donation, please press the button below. This is Paypal's payment system; you don't need a Paypal account to use it: you can use several types/brands of credit and debit card.

Peter Kahrel's paypal account

Download script


Back to script index

Installing and running scripts

Questions, comments? Get in touch