8 Replies Latest reply on Aug 11, 2009 3:12 AM by J van E

    CS4: Can't find and replace returns

    J van E Level 1

      I am working with the FindChangeList.txt and the script that comes with it to replace common errors in the textfiles I always get. One of those errors is: a hard return too many. Usually this means that after a paragraph there are three returns instead of two returns.

      Now in the old days (CS3) I used to find and replace them using \p, but apparently it has changed to ~b (???). The weird thing is that I can find and replace (using the script) manual returns (\n) with normal returns (~b), but I can't find and change those normal returns (~b) at all. I tried it with 'text' and 'grep' and also ~b~b+ nd so on, but nothing works...


      So... how can I find and replace three or more returns with two...?

        • 1. Re: CS4: Can't find and replace returns
          absqua Level 4

          You'll want to add a line like:


          grep    {findWhat:"\r{3,}"}    {changeTo:"\r\r"}


          to your FindChangeList.txt file. You'll also want to comment out (if you haven't already) the line that says


          grep    {findWhat:"\r\r+"}    {changeTo:"\r"}


          to avoid replacing your two returns with one.



          • 2. Re: CS4: Can't find and replace returns
            J van E Level 1

            Thanks, I tried it, but it still doesn't work... It's very weird because ALL my other lines in the FindChangeList.txt do work! And when I use the find/change option in InDesign CS4 itself, I can also find and replace all hard returns without any problems (^b with text and ~b with GREP). I really don't understand why the script doesn't work with it...

            • 3. Re: CS4: Can't find and replace returns
              Peter Kahrel Adobe Community Professional & MVP

              You may have to escape the backslashes, so \\r instead of \r



              • 4. Re: CS4: Can't find and replace returns
                J van E Level 1

                No, doesn't work either. I just don't get it. I've also been trying to find and replace things like " and ' but that also doesn't work. While it DOES with the normal find/change option! Maybe the script simply can't handle everything...

                • 5. Re: CS4: Can't find and replace returns
                  absqua Level 4

                  This may be a stupid question. Sorry if it is. Are you sure you're modifying the correct FindChangeList.txt? It needs to be in a folder called FindChangeSupport in the same folder as your script. Or perhaps you copied your CS3 file rather than modifying the CS4 file? They may be structured differently.


                  Just an idea.



                  • 6. Re: CS4: Can't find and replace returns
                    J van E Level 1

                    Not a stupid question at all, but I am using the right file. The other searches/lines DO work. And I've found the file by using the Show in finder option in CS4. So nothing is going wrong in that regard. As said, I can even replace manual (soft) returns with normal ones, but finding the normal ones (and things like " and ' ) is impossible...


                    I wonder if someone here has a WORKING file with similar searches as I want that could be uploaded here...?


                    BTW I of course also tried the line that's in the list by default after installing CS4:



                    grep {find what:"\r\r+"} {change to:"\r"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find all double returns and replace with single returns.

                    but even that one just doesn't work (not even when I disable all other lines). You would expect a sample to work correctly. It's a mystery!
                    I think I am on to something... I reinstalled the original sample list and now the returns can be found... Seems my line with the soft/manual returns does something bad to the line with the normal hard returns, even when that line is disabled... So tomorrow (don't have time anymore today) I will see if I can get things done by using two scripts: applescript for the first searches and javascript for the ones that won't work well together...
                    • 7. Re: CS4: Can't find and replace returns
                      J van E Level 1

                      Well, I am glad there are Applescript AND Javascript samples... because I managed to find and replace soft returns with hard returns with the Javascript and after that I run the Applescript to do the rest (replace double spaces, double tabs and too many hard returns).


                      But I'm not done yet... because I can't find and replace " and ' . I guess the problem with " is that this is used in the list itself. But even when I type \" or ~", I won't work.

                      Man, you would think finding and replacing things using this script was a simple matter of entering the same info as you do in the find and replace dialogue in InDesign... Why are scripts so much harder to get working?