4 Replies Latest reply on Nov 1, 2011 5:54 PM by romanobstuder

    FindChangeList.txt edit not doing the style change

    romanobstuder Level 1

      I am using the "standard" ID script FindChangeByList.jsx

       

      I can get the text change working but not the applied Character Style.

      I did create the Char Style off course. And manually test it in ID.

       

      Can somebody give me some pointers?

      Thank you very much

       

      Romano

       

      grep{findWhat:" a"}{changeTo:" b"}{appliedCharacterStyle:"superscript"}
        • 1. Re: FindChangeList.txt edit not doing the style change
          csm_phil Level 4

          Hi Romano,

           

          Can you please try the below JS code, This code will create the character style and apply the replaced text.

           

           

          var myDoc = app.activeDocument;
          var myStyle;
          try{
              myStyle = myDoc.characterStyles.item("s").name;
              }
          catch (myError){
              myStyle = myDoc.characterStyles.add({name:"s"});
              }
          
          app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
          app.findTextPreferences.findWhat = "a ";
          app.changeTextPreferences.appliedCharacterStyle=myStyle.toString();
          app.changeTextPreferences.changeTo= "b ";
          myDoc.changeText();
          app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
          

           

           

          thx

          csm_phil

          • 2. Re: FindChangeList.txt edit not doing the style change
            romanobstuder Level 1

            Hi csm_phil

             

            Thank you very much for the provided script.

            I have tested it and it works very well.

             

            However I would like to use the

            FindChangeByList.jsx

            This is one of the standard scripts that ID gets shiped with.

            The script uses an external .txt file with the list of changes that one wants to perform.

            My own script has many other tasks to perform and in this instant it is a great solution to "outsource" the final clean up task.

             

            I already call the script successfully to do a few lines like below.

             

            The only component that does not work is in the last line, the change to a character style.

            I have tried the "text" and the "grep" version of it.

            Everytime the search and replace works but the change into the character style does not.

             

            grep{findWhat:" a"}{changeTo:" b"}{appliedCharacterStyle:"superscript"}

             

            Thank you for any further hints

            Romano

             

            :

            grep{findWhat:"  +"}{changeTo:" "}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all double spaces and replace with single spaces.
            grep{findWhat:"\r "}{changeTo:"\r"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all returns followed by a space And replace with single returns.
            grep{findWhat:" \r"}{changeTo:"\r"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all returns followed by a space and replace with single returns.
            //grep{findWhat:"\t\t+"}{changeTo:"\t"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all double tab characters and replace with single tab characters.
            //grep{findWhat:"\r\t"}{changeTo:"\r"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all returns followed by a tab character and replace with single returns.
            //grep{findWhat:"\t\r"}{changeTo:"\r"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all returns followed by a tab character and replace with single returns.
            //grep{findWhat:"\r\r+"}{changeTo:"\r"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all double returns and replace with single returns.
            text{findWhat:" - "}{changeTo:"^="}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all space-dash-space and replace with an en dash.
            text{findWhat:"--"}{changeTo:"^_"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}Find all dash-dash and replace with an em dash.
            grep{findWhat:"^\\*+"}{changeTo:"\\t$0 ~i"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:true}At the beginning of a paragraph, find: any number of Asterix (*) -> replace with: tab, same amount of Asterix, tab, indent here.
            grep{findWhat:"^\\- "}{changeTo:"\~= ~i"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:true}At the beginning of a paragraph, find: Hyphen, Space -> replace with: n-dash, indent here.
            //



            grep{findWhat:" a"}{changeTo:" b"}{appliedCharacterStyle:"superscript"}
            • 3. Re: FindChangeList.txt edit not doing the style change
              MatthewMariani Level 1

              Hi Romano,

               

              Looks like you might be mixing up your grep change preferences versus options.

               

              Will this work?

              grep{findWhat:" a"}{changeTo:" b", appliedCharacterStyle:"superscript"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:true}

              Matthew

              • 4. Re: FindChangeList.txt edit not doing the style change
                romanobstuder Level 1

                Hi Matthew

                I did not get that the Change to and the applied Style needs to be in the same curly braket.

                Now that I understand this all works well.

                I also needed to escape the closing braket in the text, just for reference I placed it here.

                 

                grep{findWhat:" a\\)| b\\)| c\\)| d\\)| e\\)"}{changeTo:"$0", appliedCharacterStyle:"superscript"}{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:true}

                 

                Thank you very much for your help

                Romano