24 Replies Latest reply on Nov 11, 2016 12:05 PM by Obi-wan Kenobi

    Help needed for Find and Replace

    tpk1982 Level 4

      Hi,

       

      I am trying to find and replace the words from .txt file to indesign contents. If i have repeated words in .txt file the indesign also did for 3 times. The below image illustrates much better. Sorry i am improving my english to convey the requirement better. 

       

      Screen Shot 2016-11-08 at 5.32.17 PM.png

       

      Script Tried:

       

      myfndchange();
      function myfndchange(){
      var myFolder = File.openDialog("Select the TXT file to Proceed",isSupportedTXT,true);
      if(myFolder!=null){FilePath=decodeURI(myFolder);}    
      if(myFolder==null){return;}
      var datafile = new File(FilePath);
      datafile.open('r') ;
      
      
      while (!datafile.eof){
          strLineIn = datafile.readln();
          colorArray = strLineIn.split("\t");
          var myColumn1=colorArray[0];
          var myColumn2=colorArray[1];
          var flag=0;
          x=myColumn1.split(" ");
          app.findTextPreferences = app.changeTextPreferences = null;
          app.findChangeTextOptions.includeLockedLayersForFind = true;
          app.findChangeTextOptions.includeLockedStoriesForFind = true;
          app.findChangeTextOptions.includeHiddenLayers = false;
          app.findChangeTextOptions.includeMasterPages = true;
          app.findChangeTextOptions.includeFootnotes = true;
          app.findChangeTextOptions.caseSensitive = false;
          app.findChangeTextOptions.wholeWord = true;
          mydoc=app.documents[0];
          app.findTextPreferences = null;     app.changeTextPreferences = null;  
      
      
          app.findTextPreferences.findWhat=myColumn1;
          var myfound=mydoc.findText();
          for(i=0;i<myfound.length;i++){
              if(myfound[i].words.length===x.length){
                  app.changeTextPreferences.changeTo  = myColumn1+"/"+myColumn2;
                  myfound[i].changeText()
                  }
              }
          }
      }
      
      
      function isSupportedTXT(file) {
      try {
      if (file instanceof Folder)
      return true;
      else
      return file.name.match(/\.txt$/i) != null;
      } catch (e) {
      alert("Error in isSupported method: " + e);
      }
      }
      

       

       

      Thanks,

      K

        • 1. Re: Help needed for Find and Replace
          tpk1982 Level 4

          Hello Experts,

           

          Any quick suggestions is appreciated. I hope somebody help to sort out the issue.

           

          Regards,

          Karthi

          • 2. Re: Help needed for Find and Replace
            Obi-wan Kenobi Adobe Community Professional

            Hi Karthi,

             

            I think I've understood what you mean!! 

             

            Try this:

             

            mydoc=app.documents[0];  
            myfndchange();  
            function myfndchange(){  
            var myFolder = File.openDialog("Select the TXT file to Proceed",isSupportedTXT,true);  
            if(myFolder!=null){FilePath=decodeURI(myFolder);}      
            if(myFolder==null){return;}  
            var datafile = new File(FilePath);  
            datafile.open('r') ;  
              
              
            while (!datafile.eof){  
                strLineIn = datafile.readln();  
                colorArray = strLineIn.split("\t");  
                var myColumn1=colorArray[0];  
                var myColumn2=colorArray[1];  
                var flag=0;  
                x=myColumn1.split(" ");  
                app.findGrepPreferences = app.findGrepPreferences = null;   
                app.findGrepPreferences.findWhat = myColumn1 + "(?!/)";  
                var myfound=mydoc.findGrep();  
                for(i=0;i<myfound.length;i++){  
                    if(myfound[i].words.length===x.length){  
                        app.changeGrepPreferences.changeTo  = myColumn1+"/"+myColumn2;  
                        myfound[i].changeGrep()  
                        }  
                    }  
                app.findGrepPreferences = app.findGrepPreferences = null;   
                }  
            }  
              
              
            function isSupportedTXT(file) {  
            try {  
            if (file instanceof Folder)  
            return true;  
            else  
            return file.name.match(/\.txt$/i) != null;  
            } catch (e) {  
            alert("Error in isSupported method: " + e);  
            }  
            }  
            

             

             

            (^/)

            • 3. Re: Help needed for Find and Replace
              Jump_Over Level 5

              Hi,

               

              I suggest to read entire txt file --> split it by lines --> make an array unique --> use it as a base for find...replace procedure

               

              Jarek

              1 person found this helpful
              • 4. Re: Help needed for Find and Replace
                Obi-wan Kenobi Adobe Community Professional

                This version seems to be faster!

                 

                myDoc = app.documents[0];    
                myFindchange();    
                
                
                function myFindchange () {
                    var myFolder = File.openDialog("Select the TXT file to Proceed",isSupportedTXT,true);    
                    if (myFolder != null)  FilePath=decodeURI(myFolder);       
                    if (myFolder == null)  return;    
                    var datafile = new File(FilePath);    
                    datafile.open();
                    var myWords = datafile.read();  
                    myWords = myWords.split("\n");
                    W = myWords.length;
                    datafile.close(); 
                
                
                    while (W--) {
                        myWord = myWords[W].split("\t");
                        var myWord0 = myWord[0];    
                        var myWord1 = myWord[1];    
                        app.findGrepPreferences = app.changeGrepPreferences = null; 
                        app.findGrepPreferences.findWhat = myWord0 + "(?!/)";    
                        var myfound = myDoc.findGrep();    
                            for(i = 0; i < myfound.length; i++){    
                                app.changeGrepPreferences.changeTo = "$0/" + myWord1;    
                                myfound[i].changeGrep()    
                                }    
                        }
                    app.findGrepPreferences = app.changeGrepPreferences = null;     
                }
                
                
                function isSupportedTXT (file) {    
                    try {    
                        if (file instanceof Folder)  return true;    
                        else  return file.name.match(/\.txt$/i) != null;    
                        }
                    catch (e) {
                        alert("Error in isSupported method: " + e);
                        }
                }    
                

                 

                 

                (^/)

                1 person found this helpful
                • 5. Re: Help needed for Find and Replace
                  tpk1982 Level 4

                  Hi Obi,

                   

                  Thanks for the quick reply.  I expected your answer after i posted You did that..

                   

                  Thanks Jump_Over for your suggestions...

                   

                  Thread 4..This version seems to be faster!.. NOT WORKING>> IT ALMOST RUNNING ENDLESS

                   

                  Regards,

                  K

                  • 6. Re: Help needed for Find and Replace
                    tpk1982 Level 4

                    Hi Obi,

                     

                    I am facing with the code as you provided in thread 2.

                     

                    See the below screen shot:

                     

                    Screen Shot 2016-11-09 at 1.00.41 PM.png

                     

                    Please see the red marked line. It should not be updated. Also the replaced things also wrong.

                     

                    It can be eliminated in Text search instead of Grep. Because it have

                     

                    app.findChangeTextOptions.wholeWord = true;

                     

                    Thanks,

                    K

                    • 7. Re: Help needed for Find and Replace
                      tpk1982 Level 4

                      Hello Obi,

                       

                      Any suggestions please

                      • 8. Re: Help needed for Find and Replace
                        Jump_Over Level 5

                        I suggest

                        (keeping idea read - split - unique - change):

                        Array.prototype.unique = function() {
                            var res = [], k, i, loop;
                            loop: for (k = 0; k < this.length; k++) {
                                        for (i = 0; i < res.length; i++)
                                            if (this[k] == res[i]) continue loop;
                                        res.push(this[k]);   
                                        }
                            return res;
                            }
                        //
                        var
                            myDoc =app.documents[0],
                            myFile = File.openDialog("Select a TXT file to proceed","*.txt",false),
                            mySource = [], cLine, cCol1, cCol2;
                        //   
                        if (!myFile) exit();
                        ///
                        app.findTextPreferences = app.changeTextPreferences = null;
                        //   
                        with (app.findChangeTextOptions){
                            includeLockedLayersForFind = true; 
                            includeLockedStoriesForFind = true; 
                            includeHiddenLayers = false; 
                            includeMasterPages = true; 
                            includeFootnotes = true; 
                            caseSensitive = false; 
                            wholeWord = true; 
                            }
                        //
                        myFile.open('r');
                        do
                            mySource.push(myFile.readln());
                            while (!myFile.eof);
                        myFile.close();
                        //
                        mySource = mySource.unique();
                        //
                        while (cLine = mySource.pop()) {
                            cCol1 = cLine.split("\t")[0];
                            cCol2 = cLine.split("\t")[1];
                            app.findTextPreferences.findWhat = cCol1;
                            app.changeTextPreferences.changeTo = cCol1 + "/" + cCol2;
                            myDoc.changeText();
                            }
                        

                        Jarek

                        1 person found this helpful
                        • 9. Re: Help needed for Find and Replace
                          tpk1982 Level 4

                          Hi Jarek,

                           

                          Awesome.. it working as expected.. you are my time saver man.. for this reason i created a new thread..

                           

                          FindGrep() and FindText() together

                           

                          Thank you so much

                          Thanks Obi for the part of this thread.. your's suggestions also valuable and new learning for me

                           

                          Regards,

                          K

                          • 10. Re: Help needed for Find and Replace
                            tpk1982 Level 4

                            Hello Jarek,

                             

                            One small issue happened. See below:

                             

                            Screen Shot 2016-11-11 at 5.44.53 PM.png

                             

                            The word "STARTING AT" used in "SALE STARTING AT", so it put the two words (10, 11) in "SALE STARTING AT"

                             

                            Could you please suggest?

                             

                            Thanks,

                            K

                            • 11. Re: Help needed for Find and Replace
                              Obi-wan Kenobi Adobe Community Professional

                              Karthi,

                               

                              You wasn't not clear at all!

                               

                              If I understand now well, the right list you could have could be this one:

                               

                              Obi-wan 1

                              Obi-wan 2

                              Obi-wan 3

                              Luke 4

                              Han 5

                              Luke 6

                               

                              … and the result you would want would be this one:

                               

                              Obi-wan/1/2/3

                              Luke/4/6

                              Obi-wan/1/2/3

                              Han/5

                              Obi-wan/1/2/3

                              Darth Fourth

                              Luke/4/6 Fifth

                              Obi-wan/1/2/3

                               

                              Right?  [it's just for me to understand!]

                               

                              Tests:

                               

                              Capture d’écran 2016-11-11 à 14.22.40.png

                               

                              (^/)

                              • 12. Re: Help needed for Find and Replace
                                Obi-wan Kenobi Adobe Community Professional

                                Karthi,

                                 

                                Would do you want?

                                 

                                SALE STARTING AT/10

                                SALE STARTING AT/10

                                STARTING AT/11

                                 

                                (^/)

                                • 13. Re: Help needed for Find and Replace
                                  Jump_Over Level 5

                                  Hi,

                                   

                                  The devil is in the details - as always

                                   

                                  I thinks it should go with Grep

                                  alike:

                                  Array.prototype.unique = function() {
                                      var res = [], k, i, loop;
                                      loop: for (k = 0; k < this.length; k++) {
                                                  for (i = 0; i < res.length; i++)
                                                      if (this[k] == res[i]) continue loop;
                                                  res.push(this[k]);   
                                                  }
                                      return res;
                                      }
                                  //
                                  var
                                      myDoc =app.documents[0],
                                      myFile = File.openDialog("Select a TXT file to proceed","*.txt",false),
                                      mySource = [], cLine, cCol1, cCol2;
                                  //   
                                  if (!myFile) exit();
                                  ///
                                  app.findGrepPreferences = app.changeGrepPreferences = null;
                                  //   
                                  with (app.findChangeGrepOptions){
                                      includeLockedLayersForFind = true; 
                                      includeLockedStoriesForFind = true; 
                                      includeHiddenLayers = false; 
                                      includeMasterPages = true; 
                                      includeFootnotes = true; 
                                      //caseSensitive = false; 
                                      //wholeWord = true; 
                                      }
                                  //
                                  myFile.open('r');
                                  do
                                      mySource.push(myFile.readln());
                                      while (!myFile.eof);
                                  //
                                  mySource = mySource.unique();
                                  //
                                  while (cLine = mySource.pop()) {
                                      cCol1 = cLine.split("\t")[0];
                                      cCol2 = cLine.split("\t")[1];
                                      app.findGrepPreferences.findWhat = "(?i)^" + cCol1 + "$";
                                      app.changeGrepPreferences.changeTo = cCol1 + "/" + cCol2;
                                      myDoc.changeGrep();
                                      }
                                  

                                   

                                  Jarek

                                  • 14. Re: Help needed for Find and Replace
                                    tpk1982 Level 4

                                    Hi Jarek & Obi,

                                     

                                    Sorry if i confused anything. Yes i need as you said in thread 12.

                                     

                                    @Jarek: I avoid using Grep search because it does not have case sensitive option. i tried from my end and it is working fine...

                                     

                                    @Obi: Thanks again for your effort

                                     

                                    The below script is working for me

                                     

                                    Array.prototype.unique = function() { 
                                        var res = [], k, i, loop; 
                                        loop: for (k = 0; k < this.length; k++) { 
                                                    for (i = 0; i < res.length; i++) 
                                                        if (this[k] == res[i]) continue loop; 
                                                    res.push(this[k]);   
                                                    } 
                                        return res; 
                                        } 
                                    // 
                                    var 
                                        myDoc =app.documents[0], 
                                        myFile = File.openDialog("Select a TXT file to proceed","*.txt",false), 
                                        mySource = [], cLine, cCol1, cCol2; 
                                    //   
                                    if (!myFile) exit(); 
                                    /// 
                                    app.findTextPreferences = app.changeTextPreferences = null; 
                                    //   
                                    with (app.findChangeTextOptions){ 
                                        includeLockedLayersForFind = true; 
                                        includeLockedStoriesForFind = true; 
                                        includeHiddenLayers = false; 
                                        includeMasterPages = true; 
                                        includeFootnotes = true; 
                                        caseSensitive = false; 
                                        wholeWord = true; 
                                        } 
                                    // 
                                    myFile.open('r'); 
                                    do 
                                        mySource.push(myFile.readln()); 
                                        while (!myFile.eof); 
                                    myFile.close(); 
                                    // 
                                    mySource = mySource.unique(); 
                                    // 
                                    var flag=0;
                                         
                                    while (cLine = mySource.pop()) { 
                                        cCol1 = cLine.split("\t")[0]; 
                                        cCol2 = cLine.split("\t")[1]; 
                                        x=cCol1.split(" ");
                                       
                                        app.findTextPreferences.findWhat = cCol1; 
                                                    var myfound=myDoc.findText(true); 
                                    
                                    
                                        for(i=0;i<myfound.length;i++){
                                                    xx=0;
                                                    for(j=0;j<x.length;j++){   
                                                        xx=xx+myfound[i].words[j].characters.length;
                                                    }
                                                    if(myfound[i].words.length>1){xx=xx+myfound[i].words.length-1;}
                                                   
                                                    if(xx===cCol1.length){   
                                                        app.changeTextPreferences.changeTo  = cCol1+"/"+cCol2;
                                                          try{myfound[i].changeText();}
                                                          catch(er){
                                                              if(flag==0){
                                                                  alert(cCol1+"\n");
                                                                  flag=1;
                                                                  }
                                                              }
                                                        }   
                                                    }   
                                                if(myfound.length==0){ alert(cCol1+"\n")}
                                                }   
                                         
                                    }
                                    

                                     

                                    Thanks,

                                    K

                                    • 15. Re: Help needed for Find and Replace
                                      Obi-wan Kenobi Adobe Community Professional

                                      Jarek,

                                       

                                      I try to play the game with other text!

                                      For that, First, I apply a condition, then I search on this condition!

                                       

                                      My list is:

                                       

                                      Obi-wan1
                                      Master Obi-wan2
                                      Obi-wan The Jedi3
                                      Obi-wan Kenobi4

                                       

                                      My text is:

                                       

                                      I’m Obi-wan!

                                      Master Obi-wan!

                                      Obi-wan The Jedi!

                                      Obi-wan Kenobi!

                                       

                                      … and I would want to get this:

                                       

                                      I’m Obi-wan/1!

                                      Master Obi-wan/2!

                                      Obi-wan The Jedi/3!

                                      Obi-wan Kenobi/4!

                                       

                                      But your modified script aborts before the second "while"! An idea? Thanks in advance! 

                                       

                                      Array.prototype.unique = function() {  
                                          var res = [], k, i, loop;  
                                          loop: for (k = 0; k < this.length; k++) {  
                                                      for (i = 0; i < res.length; i++)  
                                                          if (this[k] == res[i]) continue loop;  
                                                      res.push(this[k]);     
                                                      }  
                                          return res;  
                                          }  
                                      
                                      var  
                                          myDoc =app.documents[0],  
                                          myFile = File.openDialog("Select a TXT file to proceed","*.txt",false),  
                                          mySource = [], cLine, cCol1, cCol2;  
                                          
                                      if (!myFile) exit();  
                                         
                                      myFile.open('r');  
                                      do  
                                          mySource.push(myFile.readln());  
                                          while (!myFile.eof);  
                                      
                                      
                                      mySource = mySource.unique();  
                                      
                                      
                                      while (cLine = mySource.pop()) {  
                                          cCol1 = cLine.split("\t")[0];
                                          app.findGrepPreferences = app.changeGrepPreferences = null;  
                                          app.findGrepPreferences.findWhat = cCol1;  
                                          app.changeGrepPreferences.appliedConditions = ["OBW"]; 
                                          myDoc.changeGrep();  
                                          }  
                                      while (cLine = mySource.pop()) {  
                                          cCol1 = cLine.split("\t")[0];
                                          cCol2 = cLine.split("\t")[1];
                                          app.findGrepPreferences = app.changeGrepPreferences = null;  
                                          app.findGrepPreferences.findWhat = "(?<!.)" + cCol1 + "(?!.)";  
                                          app.findGrepPreferences.appliedConditions = ["OBW"];
                                          app.changeGrepPreferences.changeTo = "$0/" + cCol2;
                                          app.changeGrepPreferences.appliedConditions = []; 
                                          myDoc.changeGrep();  
                                          }
                                      app.findGrepPreferences = app.changeGrepPreferences = null;  
                                      

                                       

                                      (^/)

                                      • 16. Re: Help needed for Find and Replace
                                        Jump_Over Level 5

                                        Hi,

                                         

                                        At the end of 1st 'while' mySource become an empty array ==> method pop() decrease it by 1 returning last element

                                         

                                        Jarek

                                        • 17. Re: Help needed for Find and Replace
                                          Obi-wan Kenobi Adobe Community Professional

                                          Jarek,

                                           

                                          I saw that but I don't find the way to reinitiate "mySource'! 

                                           

                                          (^/)

                                          • 18. Re: Help needed for Find and Replace
                                            Obi-wan Kenobi Adobe Community Professional

                                            OK! 

                                             

                                            Array.prototype.unique = function() {  
                                                var res = [], k, i, loop;  
                                                loop: for (k = 0; k < this.length; k++) {  
                                                            for (i = 0; i < res.length; i++)  
                                                                if (this[k] == res[i]) continue loop;  
                                                            res.push(this[k]);     
                                                            }  
                                                return res;  
                                                }  
                                            
                                            var  
                                                myDoc =app.documents[0],  
                                                myFile = File.openDialog("Select a TXT file to proceed","*.txt",false),  
                                                mySource = [], cLine, cCol1, cCol2;  
                                                
                                            if (!myFile) exit();  
                                               
                                            myFile.open('r');  
                                            do  
                                                mySource.push(myFile.readln());  
                                                while (!myFile.eof);  
                                            
                                            
                                            mySource1 = mySource.unique();
                                            
                                            
                                            while (cLine = mySource1.pop()) {  
                                                cCol1 = cLine.split("\t")[0];
                                                app.findGrepPreferences = app.changeGrepPreferences = null;  
                                                app.findGrepPreferences.findWhat = cCol1;  
                                                app.changeGrepPreferences.appliedConditions = ["OBW"]; 
                                                myDoc.changeGrep();  
                                                }
                                            
                                            
                                            mySource2 = mySource.unique();
                                            
                                            
                                            while (cLine = mySource2.pop()) {  
                                                cCol1 = cLine.split("\t")[0];
                                                cCol2 = cLine.split("\t")[1];
                                                app.findGrepPreferences = app.changeGrepPreferences = null;  
                                                app.findGrepPreferences.findWhat = "(?<!.)" + cCol1 + "(?!.)";  
                                                app.findGrepPreferences.appliedConditions = ["OBW"];
                                                app.changeGrepPreferences.changeTo = "$0/" + cCol2;
                                                app.changeGrepPreferences.appliedConditions = []; 
                                                myDoc.changeGrep();  
                                                }
                                            app.findGrepPreferences = app.changeGrepPreferences = null;  
                                            

                                             

                                             

                                            To finish, just need to insert the creation of the condition "OBW" and its deletion at the end!

                                             

                                            (^/)

                                            • 19. Re: Help needed for Find and Replace
                                              Jump_Over Level 5

                                              Hi,

                                               

                                              Use "for" instead of while.

                                              • 20. Re: Help needed for Find and Replace
                                                Obi-wan Kenobi Adobe Community Professional

                                                Done! Thanks Jarek, your code is coo! 

                                                 

                                                Array.prototype.unique = function() {  
                                                    var res = [], k, i, loop;  
                                                    loop: for (k = 0; k < this.length; k++) {  
                                                                for (i = 0; i < res.length; i++)  
                                                                    if (this[k] == res[i]) continue loop;  
                                                                res.push(this[k]);     
                                                                }  
                                                    return res;  
                                                    }  
                                                
                                                var  
                                                    myDoc = app.documents[0],
                                                    myCondition = myDoc.conditions.add ({name: "OBW"}),
                                                    myFile = File.openDialog("Select a TXT file to proceed","*.txt",false),  
                                                    mySource = [], cLine, cCol1, cCol2;  
                                                    
                                                if (!myFile) exit();  
                                                   
                                                myFile.open('r');  
                                                do  
                                                    mySource.push(myFile.readln());  
                                                    while (!myFile.eof);  
                                                
                                                
                                                mySource1 = mySource.unique();
                                                
                                                
                                                while (cLine = mySource1.pop()) {  
                                                    cCol1 = cLine.split("\t")[0];
                                                    app.findGrepPreferences = app.changeGrepPreferences = null;  
                                                    app.findGrepPreferences.findWhat = cCol1;  
                                                    app.changeGrepPreferences.appliedConditions = [myCondition]; 
                                                    myDoc.changeGrep();  
                                                    }
                                                
                                                
                                                mySource2 = mySource.unique();
                                                
                                                
                                                while (cLine = mySource2.pop()) {  
                                                    cCol1 = cLine.split("\t")[0];
                                                    cCol2 = cLine.split("\t")[1];
                                                    app.findGrepPreferences = app.changeGrepPreferences = null;  
                                                    app.findGrepPreferences.findWhat = "(?<!.)" + cCol1 + "(?!.)";  
                                                    app.findGrepPreferences.appliedConditions = [myCondition];
                                                    app.changeGrepPreferences.changeTo = "$0/" + cCol2;
                                                    app.changeGrepPreferences.appliedConditions = []; 
                                                    myDoc.changeGrep();  
                                                    }
                                                app.findGrepPreferences = app.changeGrepPreferences = null;
                                                myCondition.remove();
                                                

                                                 

                                                 

                                                (^/)

                                                • 21. Re: Help needed for Find and Replace
                                                  Obi-wan Kenobi Adobe Community Professional

                                                  You mean that if I use a "for" loop, no need to reinitiate "mySource"?

                                                   

                                                  (^/)

                                                  • 24. Re: Help needed for Find and Replace
                                                    Obi-wan Kenobi Adobe Community Professional
                                                    Array.prototype.unique = function() {  
                                                        var res = [], k, i, loop;  
                                                        loop: for (k = 0; k < this.length; k++) {  
                                                                    for (i = 0; i < res.length; i++)  
                                                                        if (this[k] == res[i]) continue loop;  
                                                                    res.push(this[k]);     
                                                                    }  
                                                        return res;  
                                                        }  
                                                    
                                                    var  
                                                        myDoc = app.documents[0],
                                                        myCondition = myDoc.conditions.add ({name: "OBW"}),
                                                        myFile = File.openDialog("Select a TXT file to proceed","*.txt",false),  
                                                        mySource = [], cCol1, cCol2;  
                                                        
                                                    if (!myFile) exit();  
                                                       
                                                    myFile.open('r');  
                                                    do  
                                                        mySource.push(myFile.readln());  
                                                        while (!myFile.eof);  
                                                    
                                                    
                                                    mySource = mySource.unique();
                                                    
                                                    
                                                    for (var c = 0; c < mySource.length; c++ ) {  
                                                        cCol1 = mySource[c].split("\t")[0];
                                                        app.findGrepPreferences = app.changeGrepPreferences = null;  
                                                        app.findGrepPreferences.findWhat = cCol1;  
                                                        app.changeGrepPreferences.appliedConditions = [myCondition]; 
                                                        myDoc.changeGrep();  
                                                        }
                                                    
                                                    
                                                    for (var c = 0; c < mySource.length; c++ ) {  
                                                        cCol1 = mySource[c].split("\t")[0];
                                                        cCol2 = mySource[c].split("\t")[1];
                                                        app.findGrepPreferences = app.changeGrepPreferences = null;  
                                                        app.findGrepPreferences.findWhat = "(?<!.)" + cCol1 + "(?!.)";  
                                                        app.findGrepPreferences.appliedConditions = [myCondition];
                                                        app.changeGrepPreferences.changeTo = "$0/" + cCol2;
                                                        app.changeGrepPreferences.appliedConditions = []; 
                                                        myDoc.changeGrep();  
                                                        }
                                                    app.findGrepPreferences = app.changeGrepPreferences = null;
                                                    myCondition.remove();
                                                    

                                                     

                                                     

                                                    Need now to study well, understand and to be able to replicate all the niceties of your great code!

                                                     

                                                    Thanks a lot for the learning!

                                                     

                                                    (^/)