AppleScript to generate index for Pages

On 8 Jan 2021 SGIII said he(?) had an AppleScript that he was prepared to share.

I have a document I am working on in Pages that I'd like to add an index to.

Are you still prepared to share your script?

FN

Posted on Jan 14, 2022 12:09 PM

Reply
10 replies

Jan 14, 2022 12:46 PM in response to frankfromauckland

Hopefully, SGIII will respond and have something that does the indexing job for you in Pages.


Your plan B is to export your Pages content as Word, open that either MS-Word, or if in LibreOffice 7.2.5 or later, give chapter 15 Tables of Contents, Indexes, Bibliographies a read in the LibreOffice Writer 7.2 Guide (macOS Edition). This should not be misconstrued with fun but is a means to an end for index generation.

Jan 14, 2022 4:18 PM in response to VikingOSX

Thanks for that. Will have a look at it.

Maybe I was a bit harsh on LibreOffice. It does to the indexing, but, gets into a knott when trying to tag a word for the main index entry. It is unfortunate that Apple have not seen fit to include Indexing/Bibligraphy/Mailmerge in their otherwise very tidy product. I know one can get an AppleScript for the mail merge which works OK and Endnote ( a paid for product) does a fine job of Bibliographies.

I'll hang in here to see if SGIII may respond.

Jan 15, 2022 10:20 AM in response to SGIII

Thank you for responding and generosity in providing the links.


I am moving house over the next few days so will experiment with it when things settle down.


LibreOffice tags the words for indexing with XML tags surrounding the text. You can see this in the XML exported version of the document. If the indexing runs more than once you, end-up with the same tag repeated multiple times around the 'tagged' text. This becomes a problem when you try to mark an entry as the 'main' entry. Which tag set around the word is to be used.


All the above (re LibreOffice) is not relevant here as this is a forum for pages.


Jan 15, 2022 5:02 AM in response to frankfromauckland

Frank, here is the link to the Pages AppleScript index tool download location posted by SGIII on Sept 16, 2020. This will download as Pages - make index - annotated.scpt. Just double-click that to open in Script Editor. Recommend you also download the sample Pages document too, so you see what the script is indexing.


Just downloaded both files a few minutes ago.

Jan 15, 2022 6:12 AM in response to frankfromauckland

Yes VikingOSX found the post! The links to Dropbox downloads should still work.


If LibreOffice makes a dog's breakfast of indexing (I haven't tried it) then this script may not satisfy either.😀


It constructs page references (hyphenated when appropriate) based on search terms entered in a series of lines in the script itself. Let me know if there are any questions on how to use it. It should be straightforward.


It worked better for my purposes than I expected, with lots of flexibility. And the price is right.


But it does not provide professional formatting of the kind I understand one gets from Word (and LibreOffice?).


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript to generate index for Pages

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.