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

Change lowercase to Title Case

Explorer ,
Jan 10, 2013 Jan 10, 2013

I have a Data Merge file that has about 25,000 addresses. The hyphenated names came in as "Smith-johnson", (second name is lower case), It needs to be Smith-Johnson.

I've tried with my neanderthal GREP skills with no luck.

Any help would be appreciated.

Geoff

TOPICS
Scripting
1.5K
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

Community Expert , Jan 10, 2013 Jan 10, 2013

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = /\u\l+?-\l/.source;

names = app.activeDocument.findGrep();

for (i = names.length-1; i > -1; i--)

     names.contents = names.contents.replace (/(.)$/, function () {return arguments[1].toUpperCase()});

Peter

Translate
Community Expert ,
Jan 10, 2013 Jan 10, 2013

app.findGrepPreferences = null;

app.findGrepPreferences.findWhat = /\u\l+?-\l/.source;

names = app.activeDocument.findGrep();

for (i = names.length-1; i > -1; i--)

     names.contents = names.contents.replace (/(.)$/, function () {return arguments[1].toUpperCase()});

Peter

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 ,
Jan 12, 2013 Jan 12, 2013
LATEST

Pete's script is handy if the file has been merged to a new indesign file.

There is a way to change the case before the merge using GREP styles, saving the step of merging to an indesign file and can merge directly to a PDF (assuming the file is going to be imposed from a PDF). Full credit should go to Jongware for revealing this to me a while ago.

The full write-up is at http://colecandoo.wordpress.com/2012/08/08/no-fills-grep-styles-part-1/ but the bit that the OP is interested in is here.

In the paragraph style that contains the hyphenated names, two character styles need to be made first: one called notuppper, and one called upper. the "notupper" character style effectively has nothing applied EXCEPT in basic character formats, the case is set to NORMAL. in "upper", nothing is applied EXCEPT in basic character formats, the case is set to ALL CAPS.

The paragraph style will refer to these character styles via GREP styles. two grep styles are made and must appear in this order:

top grep: apply upper.

to text:  \b\u\l+\-\l

bottom grep: apply notuppper

to text: \b\u\l+-(?=\l)

If this doesn't make sense, read my complete post on my blog and download the sample if need be.

colly

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
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