Skip to main content
New Participant
March 20, 2013
Answered

Please help. How to remove some of index reference?

  • March 20, 2013
  • 1 reply
  • 3290 views

Sometimes I need to use an old indesign document to make another book. It is easy and fast. You do not need to define footnotes, running headers, master pages etc. 

I always have the problem with books that had index inside.

It is easy to remove an old text from the document and fill in a new text.

But if an old document had index, such reference like "see" "see also" etc. still remains unremoved (undeleted). 

The are stil listed in the index palette. 

And I don't know how can I remove them automatically from my old document before I import a new text to it.

Probably someone of you can write such simple script which can remove all index reference (or particularly such as "see" and see also") from the empty InDesign document.

I mean empty indesign document that is document without body text inside.

Thank you in advance for your help and sorry for my poor English.

This topic has been closed for replies.
Correct answer Peter Kahrel

try {

    app.activeDocument.indexes[0].topics.everyItem().remove();

} catch (_) {

}

1 reply

Peter KahrelCorrect answer
Community Expert
March 20, 2013

try {

    app.activeDocument.indexes[0].topics.everyItem().remove();

} catch (_) {

}

Inspiring
February 20, 2014
app.activeDocument.indexes[0].topics.everyItem().remove();

works very well to remove() every topic – at the first level.

But how to remove a topic at the second level (subtopic).

With the following code I fail to remove a subtopic.

#target InDesign

main();

function main()

{

          var _index = (app.documents.firstItem().indexes.length > 0) ? app.documents.firstItem().indexes.firstItem() : app.documents.firstItem().indexes.add();

          _index.topics.add({name:'topic'});

          _index.topics.itemByName('topic').topics.add({name:'subtopic'});

          if (_index.topics.itemByName('topic').topics.itemByName('subtopic').isValid)

          try

          {

                    // no success

                    _index.topics.itemByName('topic').topics.itemByName('subtopic').remove();

//~                     _index.topics.firstItem().topics.firstItem().remove();

//~                     _index.topics.firstItem().topics.everyItem().remove();

                    // success

//~                     _index.topics.everyItem().remove();

//~                     _index.topics.itemByName('topic').remove();

          }

          catch(e)

          {

                    alert( e);

          }

}

How to remove 'unused' subtopics (such with no topics and no references) only?

Martin

Inspiring
February 20, 2014

What an interesting approach!

But it would be a lot of work for me now to rebuild the complete script.

The script works very well for me and my customer and the only thing I have been looking for is a solution to delete the unused topics (see above).

So I like your last line:

app.menuActions.itemByID(78087).invoke();

Oh my, I should have seen it before.

This all I need at this time.

Thank you very much!

Martin


Dear Peter,

It looks like the topics-palette needs to get the focus before it is possible to invoke that menu action.

But why not take use of the indexes command removeUnusedTopics() instead? ;-)

That works pretty good.

Martin