2 Replies Latest reply on Jan 12, 2013 1:21 AM by Colin Flashman

    Change lowercase to Title Case

    GeofferyH Level 1

      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.



        • 1. Re: Change lowercase to Title Case
          Peter Kahrel Adobe Community Professional & MVP
          app.findGrepPreferences = null;
          app.findGrepPreferences.findWhat = /\u\l+?-\l/.source;
          names = app.activeDocument.findGrep();
          for (i = names.length-1; i > -1; i--)
               names[i].contents = names[i].contents.replace (/(.)$/, function () {return arguments[1].toUpperCase()});


          • 2. Re: Change lowercase to Title Case
            Colin Flashman Adobe Community Professional

            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.