Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script or GREP to change first letter cap to lowercase

Guest
Jul 03, 2018 Jul 03, 2018

Is there a script of grep command to be able to change a first letter cap in a word to lowercase?

I'm working on a book of quotes and the attribute name/author of the quote has a first letter cap in both the first and last name. A style is being used for the author name, that calls for all small caps with no initial (larger) cap—we want the small caps to be one size and at the moment the initial letter of each name is retaining the capital letter. The text was imported from Word.

Did a search and it seems like people have struggled with this. I've used some Grep commands in the past but am really a novice at it. Thought I found a script that would do this, but it doesn't seem to work in ID 2018.

I had started to change some of the type manually, but there are over 100 quotes so seems like there should be a better way.

If anyone can direct me to a script or grep command that would be greatly appreciated. If you suggest a grep, please spell out how I use it.

Thanks

Jeff

2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jul 05, 2018 Jul 05, 2018

Jeff,

Is there a script of grep command to be able to change a first letter cap in a word to lowercase?

This could be enough!

Capture d’écran 2018-07-05 à 23.23.53.png

Capture d’écran 2018-07-05 à 23.21.37.png

The short version:

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = "((\\b\\u\\l+\\b)\\h?){2,}";

app.findGrepPreferences.appliedCharacterStyle = "AuthorName";

myFound = app.activeDocument.findGrep();

for ( var f = 0; f < myFound.length; f++ ) myFound.changecase(ChangecaseMode.LOWERCASE);

app.findGrepPreferences = null;

Best,

Michel, for FRIdNGE

Translate
Enthusiast ,
Jul 05, 2018 Jul 05, 2018

Can you post screenshots to show what you have and how you need it to look after...also some actual text (or link to INDD file) would be helpful. Seeing the text makes it easier to find the pattern that fits your document. GREP doesn't work in isolation and the rest of the document needs to be taken into account (or at least the rest of the paragraphs the text might live in).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 05, 2018 Jul 05, 2018

Do the names always appear at the beginning of a line or anything consistent like that? You could find the first two words (obviously wouldn't work with authors with more that 2 names)...you can make all the found text lowercase, but you'll have to do it semi-manually. You could set up a keyboard shortcut for lowercase and use GREP to find the words that needed to be lowercase.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2018 Jul 05, 2018

Is the font by any chance .otf  format? OTF fonts with full character sets have the Small Caps option and also an All Small Caps option under OpenType:

Screen Shot 1.png

Screen Shot 2.png

This could be saved with a style:

Screen Shot 3.png

If it's not an OTF font it could be scripted what OS are you using?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 05, 2018 Jul 05, 2018
LATEST

Jeff,

Is there a script of grep command to be able to change a first letter cap in a word to lowercase?

This could be enough!

Capture d’écran 2018-07-05 à 23.23.53.png

Capture d’écran 2018-07-05 à 23.21.37.png

The short version:

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = "((\\b\\u\\l+\\b)\\h?){2,}";

app.findGrepPreferences.appliedCharacterStyle = "AuthorName";

myFound = app.activeDocument.findGrep();

for ( var f = 0; f < myFound.length; f++ ) myFound.changecase(ChangecaseMode.LOWERCASE);

app.findGrepPreferences = null;

Best,

Michel, for FRIdNGE

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines