Change to LowerCase
- This topic has 1 reply, 1 voice, and was last updated 5 years, 5 months ago by .
- You must be logged in to reply to this topic.
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Change to LowerCase
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Change to LowerCase
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.
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.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies allows us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
To provide the best experiences, we and our partners use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us and our partners to process personal data such as browsing behavior or unique IDs on this site and show (non-) personalized ads. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Click below to consent to the above or make granular choices. Your choices will be applied to this site only. You can change your settings at any time, including withdrawing your consent, by using the toggles on the Cookie Policy, or by clicking on the manage consent button at the bottom of the screen.
You have to be logged in to save.
Not a member? Join Today - it's FREE!