Skip to main content
Participant
October 16, 2012
Question

Can you sort indesign pages alphabetically?

  • October 16, 2012
  • 2 replies
  • 4732 views

I have a document with over 200 page and I want to sort the pages alpahetically after the heading on every page.The headings have one paragrah style. The document is singel pages, but there is two text frames on ever page. Many pages have also the same heading, so I hope to sort them in the  same order in which the document is now.

If you see the images under, I want to sort the pages alphabetically after the "heading" in bold to the right (txt:Best Buys Natural Wines)

Is it possible with a script or something else?

This topic has been closed for replies.

2 replies

Trevor:
Legend
October 16, 2012

Ok This is what you were after.

This assumes that you use a Paragraph style for your header AND THERE IS ONLY ONE HEADER ON EACH PAGE WHICH IS ONLY ONE PARAGRAPH LONG


// Script by Trevor to sort Pages according to alphabetical order of Page Headers

// http://forums.adobe.com/thread/1082984?tstart=0

var doc =  app.documents[0], myHeaders, l;

app.changeGrepPreferences = app.findGrepPreferences = null;

app.findGrepPreferences.appliedParagraphStyle = "My Header";

// Change above to the name of header style

myHeaders = doc.findGrep();

for (n=0; n < myHeaders.length-1; n++) $.writeln([myHeaders.contents]);

myHeaders.sort (function (a,b) {if (a.contents.toLowerCase() > b.contents.toLowerCase())  return 1 else return -1})

l = myHeaders.length;

while (l--) myHeaders.parentTextFrames[0].parentPage.move (LocationOptions.AT_BEGINNING);

Trevor:
Legend
October 16, 2012

It also asumes that every page has a header

Trevor:
Legend
October 21, 2012

I thought I made I nice little script here that answered your question.

With all those bottles of wine I expected at least a "Cheers mate"

Any reason why you didn't mark the question as correct?

Trevor:
Legend
October 16, 2012

Do the pages contain linked stories?

If not you can script it easily with the move command