19 Replies Latest reply on Aug 18, 2015 1:04 PM by camilo umana

    Find/Change By List help

    creusche Level 1

      Hi all,


      New to scripts here using InDesign CS6.


      I need some help on how to set up the find/change by list script in InDesign. I searched the forums but I don't quite grasp if I need my list saved as a .txt file or something else and where to save the list.


      I have a list of about 50 words (text only) (and growing) I'd like to simply find these words in my document, but not change them to anything as I need to rewrite the content to fit.


      I'm hoping there is a find next of some sort with this script so I can search the entire set of terms in one shot. (I played with the Multi/Find change script (http://automatication.com/) but it looks like that requires me to "change all" rather than find all)


      When I run the script in indesign it asks me to select a file to pull from. I currently have my list of text setup in a .txt file. (But not knowing code, I'm wondering if I need to save this text file differently or code it so the find/changebylist script can pull from this file)


      Could someone point me in the right direction, or let me know if this is the correct script to use and how to use it?


      I noticed in my script panel the find/change support folder (C:\Program Files (x86)\Adobe\Adobe InDesign CS6\Scripts\ mentioned on this site is missing from my folder.)


      Thanks for your help. Hopefully I get the hang of this soon.

        • 1. Re: Find/Change By List help
          Jump_Over Level 5



          You can go straight or try to modify 'MultiFind' script.


          I suggest to use a text conditions and go straight with this code:

                    mDoc = app.activeDocument,
                    mCond = mDoc.conditions.item("mFound"),
                    mPath = "~/Documents/ID_words_to_find.txt",
                    mDelimiter = ",",
                    mSource = File(mPath),
                    mOpen = mSource.open("r",undefined,undefined),
                    len, len1, mWordsArr, mFound;
          if (!mCond.isValid)
                    mCond = mDoc.conditions.add({
                              name: "mFound",
                              indicatorColor: UIColors.LIGHT_BLUE,
                              indicatorMethod: ConditionIndicatorMethod.USE_HIGHLIGHT,
                              underlineIndicatorAppearance: ConditionUnderlineIndicatorAppearance.SOLID
          if ( !mOpen) {alert ("Can't open a source file"; exit()};
          mWordsArr = mSource.read().split(mDelimiter);
          len = mWordsArr.length;
          app.findTextPreferences = null;
          while (len-->0) {
                    app.findTextPreferences.findWhat = mWordsArr[len];
                    mFound = mDoc.findText();
                    len1 = mFound.length;
                    while (len1-->0)
                              mFound[len1].appliedConditions = [mCond];
          app.findTextPreferences = null;


          How it works (should)?


          - a list of words to find is in a .txt file as comma-delimited (you could set other delimiter)

          - this file is named 'ID_words_to_find'  and saved in user Documents folder (you can change mPath)


          Script define a condition 'mFound' and apply it to every word from your list found in a document. They are highlighted. You can modify them.

          Notice: to remove a condition (highlight) modify a word including a space before it.





          • 2. Re: Find/Change By List help
            Salah Fadlabi Level 5

            Also check:

            A Major Job Gets Easier with GREP and FindChangeByList


            • 4. Re: Find/Change By List help
              creusche Level 1

              Thanks Jarek,


              I'm still unable to get it to work, but am wondering if it is because the .txt fil I wish to pull from is from a shared location on our network? Once I get the script to work I'd like to share it with other members of the team. So would where I save my .txt file affect the script.


              mPath = "~/Documents/ID_words_to_find.txt",


              The file I'd like to pull from is on our shared drive:


              M:/Resources/Scripts and GREP Queries/ID_words_to_find.txt



              • 5. Re: Find/Change By List help
                Jump_Over Level 5



                run this 1-liner in ESTK and watch console window. It will ask you for selecting a folder and its path will write in console. Just copy it and add a file name at the end.


                mFolder = Folder.selectDialog();



                • 6. Re: Find/Change By List help
                  camilo umana Level 1



                  I was trying to use this script but it gives me an error 25 on line 18:

                  if ( !mOpen) {alert ("Can't open a source file"; exit()};


                  May be this used as a single script?

                  • 7. Re: Find/Change By List help
                    Jump_Over Level 5



                    It was a typo:


                    if ( !mOpen) {alert ("Can't open a source file"); exit()};





                    • 8. Re: Find/Change By List help
                      camilo umana Level 1

                      Screen Shot 2014-03-30 at 05.15.04.jpg


                      Yes, it now runs but the output is found 0.


                      How to detect what is the problem?


                      If I delete the .txt file the script warns it.

                      It means the two requisites are accomplished.


                      Can you kindly make a remark?


                      Thank you.

                      • 9. Re: Find/Change By List help
                        Jump_Over Level 5



                        Exam your ID_words_to_find.txt contents. Should be comma delimited.

                        Try to find manually one of its content. I mean if your .txt contents is:




                        try to find in UI one of them. Is the result empty?



                        • 10. Re: Find/Change By List help
                          camilo umana Level 1

                          It is a beautiful script!

                          Thanks a lot.

                          (comma delimited the culprit...)



                          • 11. Re: Find/Change By List help
                            camilo umana Level 1

                            Dear Jarek,


                            Trying to use this script you wrote I founded that some single words in the list (ai, for example), that are sometimes part of a whole word (aimara), get highlighted.

                            Do you think it is a something that could be revised? Also, accented letters get unseen (anamú). Thanks for your time.


                            • 12. Re: Re: Find/Change By List help
                              [Jongware] Most Valuable Participant

                              To change the Find Text options to "Whole Word", add after the first occurrence of this line

                              app.findTextPreferences = null;


                              (the one directly above Jarek's loop) this line


                              app.findChangeTextOptions.wholeWord = true;


                              About the accented characters: are they accented as well in your text file? This should work exactly as it does in the interface: "Find text" without accents will find text without the accents.


                              GREP is able to find 'any' kind of accent for common characters with this notation:




                              but that requires a re-write of the script.

                              • 13. Re: Re: Find/Change By List help
                                camilo umana Level 1


                                Thanks a lot (as always) for this fix.

                                (It was very  that some phonemes were at the same time words in this language and the sample got contaminated..)

                                The script is now working perfectly.

                                Accented letters... also!: Theory and you were right.

                                Have a nice day.



                                Thanks again for this script.

                                Is a must in some jobs.

                                • 14. Re: Find/Change By List help
                                  camilo umana Level 1

                                  Good morning, Karek


                                  I have been using this perfect script with the last addition to catch the «whole word» as suggested by Jongware.

                                  But now some words get also tagged like the R. in this example:


                                  Eque P. Brigard molluptatio mi, ius assundam apicili quiscil igenisquia sime ium essitaur minus dit re et aut que pro ma nus voluptam esequi con rehenet, Theodore Richter assectotatio um fugiam, cones Gerald Ireland dolo mil et autatis qui ut fugis ut dolumquo eatiusd R. Tanco. Que dolorist lam voluptas dolest, tem accum eos Th. Preuss nobitam, et, nis remod quiae consedi diae rem nus dolum quis et offictas R. H. Blanch


                                  It is possible to script, in this kind of words arrange condition, only and exactly those occurrences in the list?

                                  Just to avoid something like the mark of this R. in the last line, that is not part of the list?




                                  List (comma delimited)

                                  Gerald Ireland

                                  P. Brigard
                                  R. Tanco
                                  Theodore Richter
                                  Th. Preuss

                                  • 15. Re: Find/Change By List help
                                    Jump_Over Level 5



                                    Seems to work correctly on my side. (does not highlights "R.")

                                    Are you sure there is not "R.," on your list?



                                    • 16. Re: Find/Change By List help
                                      camilo umana Level 1

                                      Hi Jarek,


                                      The idea is to know if this script can be adapted to match exactly the group of words in the list (the list comprises both names and surnames at the same time).


                                      In this case, the script only may detect R. Tanco and never R. H. Blanch, (this R. in Blanche is a coincidence that must be ignored)

                                      The idea is to mark only exactly the words in the list, in the same order. R. Tanco or nothing. Never Louise Tanco R., for example.

                                      Never R. H. Blanch, as this item is not in the list.


                                      The doubt is if this is scriptable or if in a list this is not possible.

                                      Pipe does not work, either.

                                      Thanks for your time.

                                      • 17. Re: Find/Change By List help
                                        Jump_Over Level 5



                                        As far as I can do tests with my examples - it works.

                                        But no matter what...

                                        ...you could add an "if" before setting appliedConditions.

                                        I mean lines:

                                        while (len1-->0) 
                                            if (mFound[len1].contents == mWordsArr[len])
                                                  mFound[len1].appliedConditions = [mCond];



                                        • 18. Re: Find/Change By List help
                                          camilo umana Level 1

                                          Jarek, THANKS. It is working now.

                                          The yellow words show repeated words, not in the compound list (below), that were not happily tagged, as the condition was settled.

                                          Happy week-end:



                                          • 19. Re: Find/Change By List help
                                            camilo umana Level 1



                                            Good afternoon. This script catches the same word both in uppercase and lowercase.

                                            It is possible to refine it in order to differentiate between them, just to avoid that some identical words with double meaning and different case get tagged as in acronyms?