8 Replies Latest reply on May 12, 2015 12:50 PM by rob day

    Script to change stylesheets at once?

    tetenbas

      Here is the challenge:

      In a document I have numerous stylesheets (probably more than 30, all have to be there, it's a very technical brochure with lots of different styles). As this was planned to be duplicated and used in another language, absolutely all stylesheets end with _EN (for English) and all are set to English as the language used for correct spelling and hyphenation. Now I am ready to go for the Spanish version and I would like to change all stylesheets at once to end with _SP (for Spanish) and be set to Spanish as the language to be used for spelling and hyphenation.

      Any clue someone if this can be done with a JavaScript and if yes any ideal where to find such a script?

      Thanks for any comment / help.

       

        • 1. Re: Script to change stylesheets at once?
          rob day Adobe Community Professional & MVP

          Below is AppleScript (OSX only).

           

           

          set mylanguage to "Spanish"

           

          tell application "Adobe InDesign CC 2014"

              set pstyles to all paragraph styles of active document

              repeat with i from 1 to number of items in pstyles

                  try

                      set applied language of item i of pstyles to mylanguage

                  end try

              end repeat

             

              set cstyles to all character styles of active document

              repeat with i from 1 to number of items in cstyles

                  try

                      set applied language of item i of cstyles to mylanguage

                  end try

              end repeat

             

              set applied language of every paragraph of every story of active document to mylanguage

          end tell

          • 2. Re: Script to change stylesheets at once?
            Willi Adelberger Most Valuable Participant

            I set it up differently:

            I set up all styles as children of one single basic style (not the default one), on the next step I create a folder with another basic based on the first one and all style are somehow children of this one. This folder contains all styles of one language and has the name DE-DE for German/Germany. When all styles are set up, I duplicate that folder rename it e.g. EN-US and change in its basic the language (and sometimes I need extended tracking becauseEnglish has so short expressions).

            If I would change common properties, I would have to go to the first basic style.

            I think it is important if you work with styles to get a systematic and remain with the same naming, you can also save style breadcrumbs in libraries, e.g. tables which will hang on as children of the same basic styles. It makes designing a document really fast.

            • 3. Re: Script to change stylesheets at once?
              TᴀW Adobe Community Professional & MVP

              This script will let you both change the language of the paragraph and character styles, and change the names of the styles themselves, as well as virtually any other paragraph or character style properties you can think of:

               

              http://www.id-extras.com/products/search-in-styles

              • 4. Re: Script to change stylesheets at once?
                Olfar Level 2

                You can Create New Style Group and drag all your  styles to this folder.  Inside this folder you should make one body text style as your "master style" with English language as default, next all others styles in this folder should "based on" this one.

                Then, you can duplicate your Style Group. You don't need to change  paragraph's style names inside this folder. You must only change your "master style" language to Spanish.  That's all.

                 

                In this way you can use work in one templet in English or in Spanish

                • 5. Re: Script to change stylesheets at once?
                  tetenbas Level 1

                  Thanks Rob. I tried it but for some reason (I am not good at all at scripting, it's why I came on this forum to search for help) it didn't work. As a matter of fact though, I would rather go with JavaScript instead (a little bit more at ease with this scripting). Thanks anyway for your help, much appreciated.

                  • 6. Re: Script to change stylesheets at once?
                    tetenbas Level 1

                    Olfar,

                    This is one of the 2 ways I do at the moment and I am happy with that personally. But I work with some other people and they really want the stylesheets to be called with some tiny extension to differentiate them (EN for English, SP for Spanish, DE for German, IT for Italian, etc. and all of them with their related language used. You can understand (although I do it) that it is quite boring to click on each stylesheet, change the tiny extension and change the language. This is fine for a couple of stylesheets, but when it is over 10, it's getting not only time consuming but definitively boring… Thanks anyway for the advice.

                    • 7. Re: Script to change stylesheets at once?
                      Olfar Level 2

                      tetenbas,

                      You do not need to change names of your paragraph styles. You can change only the name of your Style Group Folder (for example EN, DE, etc.), That is all.

                      • 8. Re: Script to change stylesheets at once?
                        rob day Adobe Community Professional & MVP

                        Thanks Rob. I tried it but for some reason (I am not good at all at scripting, it's why I came on this forum to search for help) it didn't work.

                        Are you using OSX? AppleScripts have to be saved from the Script Editor application. Paste, click Compile, Save as Script File Format to your InDesign Scripts folder.