4 Replies Latest reply on Dec 8, 2014 2:44 AM by camilo umana

    script with replace some of the characters respectively

    hamdifem Level 1

      I want to change some of the characters respectively

      where error

       

       

      app.findGrepPreferences = app.changeGrepPreferences = null; 

      app.changeGrepPreferences.appliedFont = "Symbol";

      app.findGrepPreferences.findWhat =  {"α", "é", "β"};

      app.changeGrepPreferences.changeTo = {"à",  "é", "á"};

      app.changeGrepPreferences.appliedCharacterStyle = myChar1;

      app.activeDocument.changeGrep(); 

      app.findGrepPreferences = app.changeGrepPreferences = null;

        • 1. Re: script with replace some of the characters respectively
          TᴀW Adobe Community Professional & MVP

          That's not going to work! This isn't .NET where everything is done for you.

           

          You'll have to take the characters, put them into 2 arrays (no need for

          objects), then loop through the arrays.

           

          findWhat and changeTo can only take a single search query.

          • 2. Re: script with replace some of the characters respectively
            hamdifem Level 1

            OK I writed a script

            but How can I change the font of "a" character

             

            main ();

            function main(){

              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

              if(app.documents.length >= 1){

                             var myDoc=app.activeDocument;

                    editT(myDoc);

                    }

                else

                 {

              alert("Pleace Open İndesign Doc");

              } 

            }

             

            function editT(myDoc)

            {

                var oldA =["a", "b", "c"]

                var newA =["1", "2", "3"]

                var changee =[["a",0],["b",0],["c",0]]

             

             

                for (var i=0; i<oldA.length; i++)

                {

               

                    app.findTextPreferences = NothingEnum.nothing;

                    app.changeTextPreferences = NothingEnum.nothing;

                    app.findChangeTextOptions.caseSensitive = true;

                    app.findChangeTextOptions.includeFootnotes = false;

                    app.findChangeTextOptions.includeHiddenLayers = false;

                    app.findChangeTextOptions.includeLockedLayersForFind = false;

                    app.findChangeTextOptions.includeLockedStoriesForFind = false;

                    app.findChangeTextOptions.includeMasterPages = false;

                    app.findChangeTextOptions.wholeWord = false;

                   

                    app.findTextPreferences.findWhat = oldA[i]

                    app.changeTextPreferences.changeTo = newA[i];

             

                    changee[i][1] = app.activeDocument.changeText().length;

             

                    myDoc.changeText();

             

                    app.findTextPreferences = NothingEnum.nothing;

                    app.changeTextPreferences = NothingEnum.nothing; 

            }

            }

            • 3. Re: script with replace some of the characters respectively
              hamdifem Level 1

              O have a question Pleace look forum

               

              4 Aralık 2014 Perşembe tarihinde,  <forums_noreply@adobe.com> yazdı:

               

                  script with replace some of the characters respectively  created by

              <https://forums.adobe.com/people/%5BAriel%5D> in *InDesign

              Scripting* - View the full discussion

              <https://forums.adobe.com/message/6985608#6985608>

               

              • 4. Re: script with replace some of the characters respectively
                TᴀW Adobe Community Professional & MVP

                Good, that script should work.

                 

                I would recommend to take out of the loop all the findChangeTextOptions

                and everything like that. It is unnecessary to reset them with each loop

                of the loop. Just do it once outside the loop, and in the loop change

                only the findWhat text and changeTo text.

                 

                Regarding your question about the font: well, that is another question

                entirely, so it should be in a new thread.

                • 5. Re: script with replace some of the characters respectively
                  camilo umana Level 1

                  Regarding your question about the font:

                  05 Mayor estudios Grep Indesign 2014 copy.jpg

                  Hamdifem, perhaps a solution is assign a ch. style before the script is run, if copy-text allows it, like in this example.

                   

                  *This seems very useful for making massive substitutions... in find-change operations, although I don't know if find/change scripts by list are in the same line. Also, it works with words but those in both lists have to had the same number of characters. How difficult could be change the lines Ariel recommended? Thanks for this piece that works very well.