9 Replies Latest reply on May 4, 2016 11:30 AM by cbishop01

    Make a words Sentence Case?

    cbishop01 Level 2

      Hi i'm making a script to change all the main changes that we do in a document.  I'm sure that grep will handle this but again i'm trying to combine about 6 different functions into one script.  How would i go about changing 2 lines of text into sentence case? The Top line would need changed and the Bottom 2 would need changed to sentence case.  Is there a way to add this grep string into my script? 


      The Title Case Works Here "This is the only line that can be left alond"

      The Sentence Case Works Needs Changed Here

      The Sentence Case Works Needs Changed Here

        • 1. Re: Make a words Sentence Case?
          cbishop01 Level 2

          Here's my script so far.  WHere the Grep style changes is i would like to use all the grep styles i have in indesign.  Or if possible certain ones. the replace will have a ton more by the time i;m done but again the Grep is what i really need help with.

          //DESCRIPTION: Running changes.


          //Replace("<CR>", "Return") 

          //~  Created by Chris Bishop - (5-3-16)  


              Replace(" <CR> ", "^p") 

              Replace("  ", " ")

              Replace(" :", ":")

              Replace(" .", ".")

              Replace("^p^p", "^p")

              Replace(" <CR>", "^p")



                  function Replace(input, output) 



                      app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing; 

                      app.findTextPreferences.findWhat = input; 

                      app.changeTextPreferences.changeTo = output; 





          //~     Grep Style Changes







          //~  THe alert message shown when running this script. 


              do { 


                  myText.pointSize = myText.pointSize - .01; 

                  } while (myTextFrame.overflows == true); 



              alert("Text already Formatted") 

          • 3. Re: Make a words Sentence Case?
            cbishop01 Level 2

            THank you i'll check these out.

            • 4. Re: Make a words Sentence Case?
              cbishop01 Level 2

              Unfortunately this will not work for me there are going to be too many variables that will go wrong if i try this.  So now instead how would i go about opening a Document .txt, .xls, .PDF etc...  after the script is finished?  I will just add in the document what all was changed and what all will need altered if anything.

              • 5. Re: Make a words Sentence Case?
                tpk1982 Level 4

                May i know the exact requirement?


                You have three lines and you need to change only first line as Title case and other two as sentence case. Is the actual requirement?

                • 6. Re: Make a words Sentence Case?
                  tpk1982 Level 4

                  this script created long year before which is useful to change case for selected paragraph style. Place your cursor in text frame and run the script


                  if ((app.documents.length != 0) && (app.selection.length != 0)) {
                  myDoc = app.activeDocument;
                  myStyles = myDoc.paragraphStyles;
                  myStringList = myStyles.everyItem().name;
                  myCaseList = ["Uppercase","Lowercase", "Title case", "Sentence case"];
                  myCases = [ChangecaseMode.uppercase, ChangecaseMode.lowercase, ChangecaseMode.titlecase, ChangecaseMode.sentencecase];
                  var myDialog = app.dialogs.add({name:"Case Changer"})
                    with (dialogRows.add()) {
                      with (dialogColumns.add()) {
                      staticTexts.add({staticLabel:"Paragraph Style:"});
                      with (dialogColumns.add()) {
                      myStyle = dropdowns.add({stringList:myStringList,selectedIndex:0,minWidth:133});
                    with (dialogRows.add()) {
                      with (dialogColumns.add()) {
                      staticTexts.add({staticLabel:"Change Case to:"});
                      with (dialogColumns.add()) {
                      myCase = dropdowns.add({stringList:myCaseList,selectedIndex:0,minWidth:133});
                  var myResult = myDialog.show();
                  if (myResult != true){
                    // user clicked Cancel
                    theStyle = myStyle.selectedIndex;
                    theCase = myCase.selectedIndex;
                    app.findPreferences = null;
                    app.changePreferences = null;
                    myFinds = myDoc.search('',false,false,undefined,{appliedParagraphStyle:myStyles[theStyle]});
                    myLim = myFinds.length;
                    for (var j=0; myLim > j; j++) {
                  } else {
                  // +++++++ Functions Start Here +++++++++++++++++++++++
                  function errorExit(message) {
                  if (arguments.length > 0) {
                    if (app.version != 3) { beep() } // CS2 includes beep() function.
                  exit(); // CS exits with a beep; CS2 exits silently.
                  1 person found this helpful
                  • 7. Re: Make a words Sentence Case?
                    cbishop01 Level 2

                    It is.  Oh i think WHen i looked at the script before on the other pages you showed me it looked like they only had one letter being changed all the time.  I got confused.  Since this is a CS2 script will it work in CC 2015?  If not what will i need to change. 


                    Also how would go about opening a File?  Or maybe opening after the Script is done instead of having TEXT ALREADY FORMATTED. have a list of things changed and things that need changed.  I'm just trying my options out to see what works the best.

                    • 8. Re: Make a words Sentence Case?
                      cbishop01 Level 2

                      Example  Say i have a file Lets just say in the Script folder for ease(I hope).  I have a PDF, Excel, Text file or whatever  PDF would be best.  called Changes.  How would i have that open when the script is done?  Or can i have a Dialog box/ Slider box display after the script is open?  Below will be how i want it formatted.  Which is why excel file or PDF will work best.   However If i could get a dialog box to display with columns that would work as well.


                      Whats ChangedChanged to
                      Double ReturnReturn
                      Space ::
                      Space ..
                      Doubles SpaceSpace
                      • 9. Re: Make a words Sentence Case?
                        cbishop01 Level 2

                        Never mind.  I found another way to do it.   Thanks for all your help.  I'm learning a ton here.