8 Replies Latest reply on Apr 30, 2010 12:33 PM by Kasyan Servetsky

    FindChangeByList script question

    JoJo Jenkins Level 1

      I'm using the FindChangByList script, and it's working beautifully. I'm using the JavaScript version.

       

      Except for one maddening thing.

       

      I'm using this line in the FindChangeByList text file:

      grep {findWhat:"^."} {appliedParagraphStyle:"NAME OF INSTRUMENT", changeConditionsMode:1919250519} {includeLockedStoriesForFind:false, includeLockedLayersForFind:false, includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true} //Change all text in story to my paragraph style called NAME OF INSTRUMENT
      

       

      The idea is that this turns all text in the story into a certain style. In this case, it's my style called NAME OF INSTRUMENT. As everyone here already knows, the regular expression ^. looks for the first character of every paragraph and turns the entire paragraph into my style. It's the most efficient way I could think of to turn an entire story into a certain style.

       

      This works fine for all styles except my style called NAME OF INSTRUMENT. For that style, and for that style only, the script deletes the first character of every paragraph.

       

      I can't figure out what's going on.

       

      Here is a screen shot of the style that's giving me the problem:

       

       

      Problem.jpg

       

      Thanks

        • 1. Re: FindChangeByList script question
          Kasyan Servetsky Level 5

          My guess is that this happens because the paragraph style is inside a group. Try something like this:

          {appliedParagraphStyle: app.activeDocument.paragraphStyleGroups.item("New _Readmiited").paragraphStyles.item("NAME OF INSTRUMENT"), changeConditionsMode:ChangeConditionsModes.REPLACE_WITH}
          

          I can't check it myself because I'm on CS3.

           

          Kasyan

          1 person found this helpful
          • 2. Re: FindChangeByList script question
            [Jongware] Most Valuable Participant

            Yeah, that's weird. In the interface, if you put some text in the Find field but only formatting in the Change field, the formatting is applied and no text is deleted.

             

            It must be a bug, somewhere -- either in the Scripting interface (since it works okay in the UI), or in the FindChange script itself.

             

            Not a solution, but you may get it to work if you put "$0" into the Replace With part in the FindChange text file. This simply changes the text to "whatever it found", so no real action is taken.

            1 person found this helpful
            • 3. Re: FindChangeByList script question
              JoJo Jenkins Level 1

              Thanks for both replies above. @Jongware, I'm sorry to be an idiot, but can you write out the exact language I would type in order to implement what you suggest? I'm totally a novice to scripting, and that includes FindChangeByList. I'm slowly learning. Thanks.

              • 4. Re: FindChangeByList script question
                [Jongware] Most Valuable Participant

                I don't use FindChange (I rolled my own ) but it seems all that's needed is to add

                 

                {changeTo:"$0"}

                 

                with a tab before and after, right after your findWhat text.

                • 5. Re: FindChangeByList script question
                  JoJo Jenkins Level 1

                  OK, figured it out. @Kayan Servetsky, you were correct that the problem was that the style I wanted to use was in a group. I tried your proposed script language but it gave me an error for some reason. So what I did was simply to copy my style out of the group it was in in and make it into a single style, and now FindChangeByList is happy again. @Jongware, your proposed solution didn't work in this case. Thanks, though.

                   

                  As long as I've got both of you here, do either of you have any ideas on my other question regarding FindChangeByList? See this link:

                  http://forums.adobe.com/thread/603032?tstart=0

                   

                  I got a bunch of answers, but they were all off topic!

                   

                  Thanks again.

                  • 6. Re: FindChangeByList script question
                    Kasyan Servetsky Level 5

                    I tried your proposed script language but it gave me an error for some reason.

                    Probably you made a typo in the group's name — notice that it contains a space: New[space]_Readmiited (I see this on your screengrab)

                    I tested the following line and it works for me — applies the style inside the group. (I removed changeConditionsMode since I'm on CS3)

                     

                    grep     {findWhat:"^."}     {appliedParagraphStyle:app.activeDocument.paragraphStyleGroups.item("New _Readmiited").paragraphStyles.item("NAME OF INSTRUMENT")}     {includeLockedStoriesForFind:false, includeLockedLayersForFind:false,includeHiddenLayers:false, includeMasterPages:false, includeFootnotes:true}
                    

                     

                    But why do you want to run FindChangeByList for this?

                    You can just apply a paragraph style to the whole story like so

                    var doc = app.activeDocument;
                    var story = doc.stories[0];
                    story.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("New _Readmiited").paragraphStyles.item("NAME OF INSTRUMENT");
                    

                    or like this

                    var doc = app.activeDocument;
                    var story = doc.stories[0];
                    var text = story.texts[0];
                    text.applyParagraphStyle(app.activeDocument.paragraphStyleGroups.item("New _Readmiited").paragraphStyles.item("NAME OF INSTRUMENT"), false);
                    

                    The latter allows you to choose wether to keep/clear overrides.

                     

                    Kasyan

                    • 7. Re: FindChangeByList script question
                      [Jongware] Most Valuable Participant
                      Probably you made a typo in the group's name — notice that it contains a space:New[space]_Readmiited (I see this on your screengrab)

                       

                      I bet you a beer the group name actually is New & Readmiited (slightly more logically). Virtually all Adobe Windows programs seem to suffer the same ignorance of a basic piece of Windows programming: "When drawing text, by default ampersands are handled differently".

                       

                      You can also see it in GREP styles (try a GREP style looking for "new&old"), as well as in Acrobat, with file names containing an ampersand.

                      • 8. Re: FindChangeByList script question
                        Kasyan Servetsky Level 5

                        I prefer to use only English letters and numbers when choosing names for styles, files, folders, etc — that's why I've never suspected of such a problem.