• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Batch update multiple TOCs in a book

New Here ,
Aug 29, 2016 Aug 29, 2016

Copy link to clipboard

Copied

Hi everyone,

I have a book with 7 documents each containing their seperate TOC. To open each document everytime, I have done changes to the book, to update each TOC in regards to page number and headers, is quite time consuming.

Therefore, I am looking for a script that could help batch update all of my TOCs in the book.

I am new to InDesign Scripting and I have been searching the forum and www for an answer to my question without results. Hence, I hope there is someone who can help confirm or reject that this is possible through scripting.

Thanks in advance!

TOPICS
Scripting

Views

958

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 29, 2016 Aug 29, 2016

Copy link to clipboard

Copied

If I search the forum, I find a lot of useful posts … e.g.:

Trouble updating TOC with Javascript

Re: What is the code for updating a table of content?

Re: Update several TOCs in the same doc. …

I’m sure, you will find also some lines, how to loop through all documents in a book and include the above mentioned parts.

Kai

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 29, 2016 Aug 29, 2016

Copy link to clipboard

Copied

Hi Kai,

Yes, the listed discussions/scripts do have something to do with updating a TOC or multiple TOCs in a document. However, I am looking for a script that can do this across a book and not just within one document.


So to simplify: does there exists a script to update multiple TOCs across a book?

Thank you in advance!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 29, 2016 Aug 29, 2016

Copy link to clipboard

Copied

Obviously there doesn’t exist such a script, otherwise you would have found it.

You said, "I am new to InDesign Scripting". This assumes that you are tryin’ to learn scripting and not only to use final scripts.

So here you find some thoughts on how to open all documents in a book:

Re: How to turn on smart text reflow for all documents in a book?

It should be not so complicated, to change the lines and include the update of the toc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 29, 2016 Aug 29, 2016

Copy link to clipboard

Copied

annek,

In a single open document, you'd update its toc as follows:

app.documents[0].createTOC (app.documents[0].tocStyles.item('toc'), true)

assuming that you used the toc style 'toc' to create the toc. Replace with the name of the toc style you used. 'true' means 'update the existing toc'.

To process all documents in your book, open the book, then run this script:

docs = app.books[0].bookContents.everyItem().getElements();

for (i = 0; i < docs.length; i++) {

  app.open (docs.fullName);

  app.documents[0].createTOC (app.documents[0].tocStyles.item('toc'), true);

}

It doesn't matter whether any of the book documents are open: the script opens a book document if it's not open, otherwise it just activates it.

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

hey Peter,

Thanks for the script, is it however possible to have teh script just find ANY TOC, regardless of the used style and update it?

Woudl be a great feature in the Book-panel menu also, to be executed whenever you synchrionize a book.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2017 Dec 20, 2017

Copy link to clipboard

Copied

LATEST

You have to supply a toc style name, and as far as I know it's not possible to determine which style was used to generate a document's toc, so, no, unfortunately, what you're after can't be done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines