Change to LowerCase

Viewing 1 reply thread
  • Author
    Posts
    • #111584
      Masood Ahmad
      Participant

      Hi,

      Following the Harbs solution on https://creativepro.com/using-grep-to-make-a-character-lowercase.php,


      finds = app.documents[0].findGrep();
      for(i=0;i<finds.length;i++){
      finds[i].contents=finds[i].contents.toLowerCase();
      }

      I tried to combine my GREP search in the code, but it didn’t work…


      app.findGrepPreferences = null;
      finds = app.findGrepPreferences.properties = ({findWhat:"[A-Z]"});
      style = getStyleByString(doc, 'Letter ID', 'characterStyles');
      for(i=0;i<finds.length;i++){
      finds[i].contents=finds[i].contents.toLowerCase();
      }

      …where “Letter ID” is the character style associated with the search.
      i.e. I want to change all the letters (A to Z) with “Letter ID” character style applied to lowercase.

      Can someone edit the code so that I do not have to write a search first in my GREP Find/Change and then run the script.

      I think it is more convenient if two things can be merged together.

      I’m on InDesign CC 2019.

      Thanks in advance.

    • #111587
      Masood Ahmad
      Participant

      I came up with this:

      //Change to Uppercase to Lowercase

      app.findGrepPreferences = app.changeGrepPreferences = null;
      app.findGrepPreferences.properties = ({findWhat:"[A-Z]"});
      app.findGrepPreferences.appliedCharacterStyle = "Letter ID";
      found = app.activeDocument.findGrep();
      for (i = 0; i < found.length; i++)
      found[i].characters[0].changecase (ChangecaseMode.lowercase);

      Though it works fine, can someone check if it needs any improvement?

      Thanks in advance.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
>