0 Replies Latest reply on May 31, 2018 2:04 AM by manuelb27477138

    Find Change Index Entries All Levels

    manuelb27477138 Level 1

      Hello!

      I find a fantastic script here:

      How to find/change/delete index entries text in documents

       

      to find and change index entries, but unfortunate my Indesign document have 4 levels of entries, and this script is only working in the first level.

      Please, Do you know how can I find and replace for all levels?

       

      #target "indesign";  
      (function () {  
          var doc = app.activeDocument,  
              indexIdx = doc.indexes.length - 1;  
                
          function removeNewEntriesFromIndex(index) {  
              var idx = index.topics.length - 1;  
                
              for (; idx >= 0; idx -= 1) {  
                  // index.topics[idx].name = index.topics[idx].name.replace(/ *NEW$/, '');  
                  index.topics[idx].name = index.topics[idx].name.replace(/ *Article 1.$/, 'Article One');  
                  index.topics[idx].name = index.topics[idx].name.replace(/ *rights$/, 'human rights'); 
              }  
          }  
            
          for (; indexIdx >= 0; indexIdx -= 1) {  
              removeNewEntriesFromIndex(doc.indexes[indexIdx]);  
          }  
      }()); 
      

       

      Is important change exactly the correct word , for example In my document are many times the word "rights", but I only want change the "rights" placed in the four level:

      Article 1. > persons > free > rights

      Like you can see in the picture:

      Screen Shot 2018-05-31 at 11.00.44.png

       

       

      Thanks so much!