6 Replies Latest reply on Sep 14, 2012 10:32 AM by Muppet Mark

    Find/Change in Applescript

    Cooroo

      I've been doing this in Quark for years, but can't think myself into ID mode! Can anyone give me the basic code necessary to search ALL the text of a document and replace, say, "Britain" with "America"?

       

      This doesn't work! but at least proves I'm trying...

       

      tell application "Adobe InDesign CS5"

                tell document 1

                repeat with i from 1 to count of stories

                                    tell story i

                                              set (every text where it is "Britain") to "America"

                                    end tell

                          end repeat

      end tell

      end tell

       

      Thanks for any help!

        • 1. Re: Find/Change in Applescript
          -hans- Level 4

          Hi,

          I'm actually on PC but try sth. like this:

           

          tell application "Adobe InDesign CS5.5"

          set find text preferences to nothing

          set change text preferences to nothing

          set find what of find text preferences to "Dolores"

          set change to of change text preferences to "Rihanna"

          set theDoc to document 1

          change text theDoc

          set find text preferences to nothing

          set change text preferences to nothing

          end tell

          • 2. Re: Find/Change in Applescript
            Cooroo Level 1

            Oh my! Didn't know 'change text' existed. That works perfectly. Now I need to narrow it down to text matching certain conditions, but that's obviously where 'find text preferences' and 'change text preferences' come into it.

             

            I can play on my own now.

             

            (You aren't Hans H who used to be so helpful on the Quark forum are you??!)

            • 3. Re: Find/Change in Applescript
              -hans- Level 4

              Hi,

               

              no. If you have RegEx SearchCriterias then have a look for the grepsearch.

              some link: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/indesign/pdfs/InDes ignCS5_ScriptingGuide_AS.pdf

               

              Hans-Gerd Claßen

               

              'Hans H.', guess I know whome you mean ... (Uhh, is this english? ;-) )

              1 person found this helpful
              • 4. Re: Find/Change in Applescript
                Cooroo Level 1

                I will read it up. I thought I could use

                 

                          set left indent of find text preferences to 9.921

                          set first line indent of find text preferences to -9.921

                          set left indent of change text preferences to 0

                          set first line indent of change text preferences to 0

                 

                (it doesn't help that the indent I need to remove is 3.5mm, which really upsets InDesign!)

                 

                Anyway, I'll try the grepsearch, which I have done before in a different context so should get back into it soon.

                 

                Thanks for your help! Many Hans make light work...


                • 5. Re: Find/Change in Applescript
                  Cooroo Level 1

                  A life changing thread!

                   

                  Funny how I just assumed that because in Quark I had to go round the houses to search and replace via Applescript, that it would be the same in ID. Just didn't look for the command because it never occurred to me that it would exist.

                   

                  This has made the job in hand wonderfully quick to solve. One more nail in the coffin of formerly-much-beloved Quark.

                  • 6. Re: Find/Change in Applescript
                    Muppet Mark Level 5

                    You know you want to switch over? Just expect your dictionary to be a whole lot thicker…