1 Reply Latest reply on Dec 6, 2013 4:52 AM by AnshulJain19

    find & change in multiple selected stories

    Douglas Gifford

      Forgive my lack of basics. I've not scripted in years and can't recall enough specifics to get re-started. I'd like to do this in applescript.

       

      What I want to achieve is to convert a bunch of musical chord names in multiple stories from "C" to "1"; "D" to "2" and so-on.

       

      Right now I do it by hand. I select the stories (they're all on one layer called "chords"). Then I replace all "C" with "1" with "stories" selected in the dialog box. Repeat with "D" and "2", "E" and "3" etc up to "B".

       

      something like

       

      tell application "Adobe InDesign CS2" 

        tell selected stories of current document

           change all "C" to "1"

           change all "D" to "2"

            etc.

        end tell

      end tell

       

      but, of course, this doesn't actually work because I don't know the right words

       

      Thanks for any help you can give me. I have hundreds of songs to change and this will save me, perhaps, days of idiot work.

        • 1. Re: find & change in multiple selected stories
          AnshulJain19 Adobe Employee

          Hi Douglas,

           

          Following script will help you in finding and changing some strings in a document. This script also sets find options, so you can lock all the other layers for which you do not want to change these strings and "set include locked layers for find of find change text options to false". So that replacement of strings only happens in unlocked layers.

          ------------------------------------------------------------------------------------------ -----------------------------------------

          tell application "Adobe InDesign CC"

           

                    --Clear the find/change preferences.

                    set find text preferences to nothing

                    set change text preferences to nothing

           

                    --Search the document for the string "c".

                    set find what of find text preferences to "c"

                    set change to of change text preferences to "1"

           

                    --Set the find options.

                    set case sensitive of find change text options to false

                    set include footnotes of find change text options to false

                    set include hidden layers of find change text options to false

                    set include locked layers for find of find change text options to false

                    set include locked stories for find of find change text options to false

                    set include master pages of find change text options to false

                    set whole word of find change text options to false

           

                    set myDoc to active document

                    tell every story of myDoc

                              set myFoundItems to find text

                              set myFoundItems to change text

           

                    end tell

          end tell

          ------------------------------------------------------------------------------------------ ---------------------------------------------------

           

          Regards

          -Anshul