4 Replies Latest reply on Dec 3, 2012 7:19 PM by LukeF11

    InDesign find/replace help request


      Hi all


      Am working a large document with a lot of repetitive elements that has been supplied in InDesign. I'm cleaning up a bunch of styling issues with a series of find/replace commands that I'm executing through the sample script that comes with INDD, so packing as many of them into the one operation is a big time saver on this project.


      There's two that I'm really struggling with:


      1. a find/replace for removing a return at the start of a text boxes throughout the document. ie. the first element in the text box is a return, then the content starts. I want the return removed so it goes straight into the content.

      2. a find/replace for removing a return which immediate follows an anchored image. If I cut and paste, I get ^a^p but if I replace that with ^a I just get the text string ^a, rather than the anchored image being left, and the return following it being removed. I understand that the find/change first removes what is being found (ie. deleted the ^a^p) then replaces it with ^a. I guess I need something that says 'find returns which follow an anchored image, and replace them with nothing', but that's way beyond my find/replace skills!


      If anyone has suggestions, text, grep, whatever, I would be very grateful.



        • 1. Re: InDesign find/replace help request
          Peter Spier Most Valuable Participant (Moderator)

          For the initial retrun in a frame, in the genereic sense that may not be doable. It depends on if the this is the first frame in a story or someplace in the middle or the last frame in a thread. Anywhere but the very beginning of the story is problem, I think, as that's just another empty paragraph in the flow of text and might not be at the top of the frame if the previous frame had a differnt size or the text was edited. How do you distinguish that from a blank paragraph in the middle of a frame that you wanted to keep (if you did in fact want to keep an empty paragraph at all)? On the other hand, if you remove consecutive returns, as the sample script does, it will take care of that case, leaving only a blank return or returns at the beginning of a story to worry about. You can find those using \A\r+ and replace with nothing. \A is the beginning of story location marker.


          (?<=~a)\r+ will find paragraph returns (or multiple returns) that follow an anchored object marker. But be warned that this is not an expression with which you should be using Change All unless there are NO cases in which you have objects anchored as the last character in your paragraphs. In such cases this would cause the following paragraph to be run in with with the paragraph containing the anchored object.  Maybe you could explain a little more about what you need to do here.

          • 2. Re: InDesign find/replace help request
            LukeF11 Level 1

            Thanks very much for this Peter.


            Your two solutions work perfectly. In the second case, the anchored objects that are followed by returns are the only anchored objects in the document, so it works fine.


            One thing is puzzling me though, the first operation -- finding the returns at the start of the story -- isn't working if it's included in the Find/change support .txt document and activated using the sample scripts. I've tried it in both JS and Applescript without any luck. Applescript throws an error, and JS just ignores that line. I'll keep fiddling to see if I can work around it, but if what I've described rings a bell, please let me know.


            thanks again.

            • 3. Re: InDesign find/replace help request
              Peter Spier Most Valuable Participant (Moderator)

              I once tried to modify the sample script and had some similar experience. Not being a scripter I can't tell you, unfortunately, why it doesn't work in some cases, even thought the query does work in Find/Change.


              You might take a look at Peter Kahrels chaining script at http://www.kahrel.plus.com/indesign/grep_query_manager.html

              • 4. Re: InDesign find/replace help request
                LukeF11 Level 1

                Thanks again for your help Peter. I guess one manual find-and-replace isn't going to kill me!