GREP question: Changing all caps to proper name punctuation

Hello,
I'm working on my subscription renewal letter.
In our mailing database, all names of people and business are in capitals. I need to change them to regular capitlization for the letter.
Example: "JOHN SMITH" should be "John Smith"
I know how to find the text, but I don't know exactly how to repace it. Help would be much appreciated.
Regards,
Eric

I found a script (coding below) by Dave Saunders: http://jsid.blogspot.com/2005/08/script-of-day-smart-title-case.html
I need it to be slightly modified so that instead of applying to the selected text, it finds (?<=Dear\s|Cher\s).+
//DESCRIPTION: Converts selected text to title case smartly
// Customize this script by either editing these arrays:
var ignoreWords = ["a","an","and","the","to","with","in","on",
"as","of","or","at","is","into","by","from","for"];
var intCaps = ["PineRidge","InDesign","NJ","UMC"];
// or by creating text files named ignoreWords.txt
// and intCaps.txt in the script's folder
ignoreWords = getIgnoreFile(ignoreWords);
intCaps = getIntCaps(intCaps);
try {
myText = app.selection[0].texts[0].contents;
} catch(e) {
exit();
theWords = myText.toLowerCase().split(" ");
//First word must have a cap, but might have an internal cap
myNewText = "";
for (var j = 0; theWords.length > j; j++) {
k = isIn(intCaps,theWords[j])
if (k > -1) {
  myNewText = myNewText + intCaps[k] + " ";
  continue;
} else {
  if ((isIn(ignoreWords,theWords[j]) > -1) && (j != 0)) {
   myNewText = myNewText + theWords[j] + " ";
  } else {
   myNewText = myNewText + InitCap(theWords[j]) + " ";
app.selection[0].texts[0].contents = myNewText.substring(0,myNewText.length - 1);
// +++++++ Functions Start Here +++++++++++++++++++++++
function getIgnoreFile(theWords) {
var myFile = File(File(getScriptPath()).parent.fsName + "/ignoreWords.txt");
if (!myFile.exists) { return theWords }
// File exists, so use it instead
myFile.open("r");
var importedWords = myFile.read();
myFile.close();
return importedWords.split("\n"); // Could filter these, but what's the point?
function getIntCaps(theWords) {
var myFile = File(File(getScriptPath()).parent.fsName + "/intCaps.txt");
if (!myFile.exists) { return theWords }
// File exists, so use it instead
myFile.open("r");
var importedWords = myFile.read();
myFile.close();
return importedWords.split("\n"); // Could filter these, but what's the point?
function getScriptPath() {
// This function returns the path to the active script, even when running ESTK
try {
  return app.activeScript;
} catch(e) {
  return e.fileName;
function isIn(aList,aWord) {
for (var i = 0; aList.length > i; i++) {
  if (aList[i].toLowerCase() == aWord) {
   return i;
return -1;
function InitCap(aWord) {
if (aWord.length == 1) {
  return (aWord.toUpperCase());
return (aWord.substr(0,1).toUpperCase() + aWord.substring(1,aWord.length))

Similar Messages

  • How do I do a mass change of face names in iphoto?  For example, I have 500 pictures named Michelle Smith, but she is married and is now Michelle Johnson.  How do I change all the photo face names to the new name en masse?

    How do I do a mass change of face names in iphoto?  For example, I have 500 pictures named Michelle Smith, but she is married and is now Michelle Johnson.  How do I change all the photo face names to the new name en masse?

    You edit the name in the Corkboard view.

  • Mac keep automatically changing ALL CAPS to lower case in Pages.

    MacBook Pro automaticaly changes all CAPS to lower case in Pages. It will automatically revert and I can't make the CAPS stay, regardless if I hold 'shift' and type or press the 'caps lock' key. Is there a setting where I can disable this feature?

    You have not said where you are copying this from but it sounds like what you have is text that is styled by CSS on a web page or ATSUI (Apple's typographic type engine) to appear ALL CAPS.
    The actual text is actually U&lc or lowercase.
    You can restyle it using:
    Menu > Format > Font > Capitalization > All Caps
    Peter

  • How do I change all caps to lowercase on Pages 08?

    How do I change all caps to lowercase on Pages 08? Help says to use 'Lower' but I can't find it on the program.

    If you have Pages '08, then you also have Numbers '08, which supports the LOWER() function.
    Copy/paste your text into column B of a Numbers table, starting at B2
    In cell C2, enter the formula =LOWER(B2).
    Fill down to the last row containing text in column B.
    Select the cells of converted text in column C. Copy
    Go back to your Pages document and go Edit > Paste Values.
    Unlike the Pages menu item (in the Format menu), which formats the text to display as lower case, the LOWER() Function does an actual conversion. The function works only in a table. It is probably supported in Pages tables as well as in tables in Numbers, but I haven't checked that.
    Regards,
    Barry

  • Animation Question: Changing all keyframe instances in a single layer all at once?

    I am working on an animated piece in Adobe Flash. I have a
    single 'head comp' layer that contains head, eyes, mouth, etc.
    layers within. I have created several keyframes in this layer to
    animate the entire head comp. Furthermore, I have several keyframes
    within that comp for lip sync, eye movements, etc.
    My problem is, I have to manually change every single
    keyframe in the head comp layer to sync up with the animation
    contained within. For example, if I have a keyframe on the main
    head comp layer-- on frame 5-- I have to manually select frame 5,
    go to Properties panel, change to "Play Once," and then type in the
    frame number in the "First" field. I then have to repeat this
    process several hundred times across the entire layer. There must
    be a faster to to sync up the whole layer. Please help!!!

    Thanks again for your help.
    I think my problem here is, I'm not trying to move any frames
    or anything. I just want to change the properties panel of each
    keyframe in the layer to "Play Once" and have the number in the
    "First" field match it's frame number (example: I want to change
    the "First" field to "10" if the keyframe starts on frame 10. That
    way it will match up with my lip sync animation on frame 10 of the
    nested layer within.) Does that make sense? I have been having to
    change each keyframe number in the layer manually. It takes
    forever.
    The "Play Once/Loop/Single Frame" option isnt available if I
    dont create a motion tween. Again, I'm not trying to move my
    animation-- just change all of the Properties at once.
    Also- if this helps- I am working in CS3.

  • Are there any scripts to change all Caps locked items to bold?

    I'm new to this program...like, 5 minutes in to using it. I make typesetted catalogs, where there are 850 or so "lots," that all have Caps locked titles. These titles also have to be in all bold. Is there any easy to take my existing text, & make it bold (like a Find/Change)?

    I presume you mean the text was typed in with the caps lock key on so it is all uppercase. There are a number of ways to do this, but which to use depends on waht you have. Do these headings have a style assigned to them? They should, and if they do all you need to do is edit the style definition to use Bold. If not you can do it with Find/Change and GREP, but we need to know if there is any punctuation and whether there is any other text inthe same paragraph, or if the titles stand alone. A screen capture would help, (and take it with non-printing characters visible, please). You can embed it in a post using the camera icon on the web page like this:

  • Changing all caps text to lower case in PSE 7 ?

    I have PSE 7.0, and am trying to add text to an image.  When I add the text, and type it in all in
    lower case, the text appears in all capitals, in text layer, and changing
    my keyboard caps lock doesn't make any difference.
    However, in the layers summary box on the right side of  screen, the text appears in lower case - but when I save, or print etc, it always shows in all capitals!
    Does anyone know any more about text editing in PSE 7.0?
    Thanks so much!
    Sasha

    First of all be sure the font you're using has small letters and not just caps. If it does, then click the tiny triangle at the far left of the options bar and choose Reset Tool.

  • Index, add all, proper name

    I am creating index entries including a large number of proper names, and I want to Add All so that every occurrence of the name is indexed, but by last name.
    I see the shortcut to create an index entry for a proper name, but in order to "Add All" I need to use the Index Panel.
    To Add All for a proper name and have it appear in the index sorted by last name, I would use the Index Panel and then type the last name in the "Sort By" box (Ex.: for "John Doe" I would type "Doe" in the "Sort By" box). Right?

    I don't think a single GREP could do it, which leads to another problem: how to prevent successive grep replaces from working again on an already reordered name?
    Try something like this. Select the entire index; set the text colour to "Red". Then do as much as possible with GREP, and do the remaining by hand. The GREP Search should specify "Red" text, the replace should set the colour back to "Black".
    Likeable GREP expressions are:
    Search: (\u\l+) (\u\l+); replace with $2, $1. That'll take care of all "John Doe" to "Doe, John"
    Search: (\u\l+ \u\.) (\u\l+); replace with $2, $1. That'll pick up "John A. Doe" to "Doe, John A."
    Search: (\u\l+ \u\l+) (\u\l+); replace with $2, $1, changes all "John Allen Doe" to "Doe, John Allen" -- but for compound surnames ("Matt Le Blanc") you'll have to double-check...
    Search: (\u\l+) (\u\l+\u\l+), replace with $2, $1, to alter "John McDoe" to "McDoe, John".
    (I can combine all of the above into a single GREP, but for clarity I've restrained myself :-) -- besides, you probably need more than one S/R run anyway. Hence the colour trick.)
    For slight variations, all you have use are these basic GREP wildcards: \u for uppercase character, \l for lowercase, '+' for one or more (hence "\u\l+" -- an uppercase followed by any positive number of lowercase). The period is a GREP wildcard, so it has to be escaped as "\.", and the parentheses define Replace groups (the $1, $2 in the replace; I put them around as "$2, $1" to switch first/last name).
    The remaining should hopefully be exceptions to these simple rules, and probably could easy be done by hand, as they stand out in red.
    >I will need to create one index entry for "Doe, John" which also identifies page numbers for "John Doe," "John A. Doe," etc., as well as a different index entry for "Mrs. John A. Doe," "Mrs. John Doe" and "Mary Doe" and the like
    That's a bigger problem, actually. The page numbers for the variations of "John [X.] Doe" will all appear as individual entries in the index. They would have to be added
    i all in the same way
    as an index entry for ID to see they're the same. Perhaps you could first generate the index, look up strays, such as one entry for "J. Doe" and one for "John Doe", and correct these in the text. Only when the index entries are okay, do the final index cleanup. And hope the text doesn't get revised.

  • Change All Field Names in a Table to have a Lowercase First Letter

    I have an SQL database with many tables.  All of the field names in each table start with an Uppercase letter. I would like to programmatically change all of the field names in each table to start with a lowercase letter.  Can this be done?
    E.g.:  "FieldName" to "fieldname"
    Thanks.

    O.K.  Just in case anyone else runs into this, I used Carl's answer to guide me in the right direction. This is my final code that created the commands I needed to run a batch (where TMaster is my schema name and the WHERE statement contains
    the datatypes in your tables):
    SELECT
    'EXEC SP_RENAME ''TMaster.'+TABLE_NAME+'.'+COLUMN_NAME+''',
    '''+LOWER(SUBSTRING(COLUMN_NAME,1,1))+SUBSTRING(COLUMN_NAME,2,255) 
    +''',
    ''COLUMN'''
    FROMINFORMATION_SCHEMA.COLUMNS
    WHEREDATA_TYPE='int'.

  • Finished script: Use grep find/change to fill in a supplied table of contents

    This script is now complete, and has been the subject of most of my previous posts. Just in case anyone wanted to know what the finished script ended as, here it is.
    Thanks so much to all. A lot of really helpful folks on this board are very responsible for the success of this task. This script is to be one of hopefully many in the creation of our records. But it's a huge leap forward. Thanks again to everyone that helped.
    Cheers,
    ~Nate
    Task:
    Automatically find town names in listings, and fill in table of contents template on page 2 accordingly.
    Example of page 2 toc, initially:
    Example of a page of content. The town names are what need to be referenced on the TOC:
    Example of page 2 toc once script is finished:
    Because of the need to include the transaction dates on the TOC (comes as a provided, tagged-text file), a simple Indesign-generated TOC can't be used alone.
    This script uses an Indesign-generated TOC that's on a master page called "T-tocGen" ... It then uses grep search and replaces to grab the needed information, and insert it into the page 2 TOC.
    The script will update a generated TOC and then search for an instance of a page number, and town name. The generated toc lists all included towns in the following format:
    (line start)## tab townName(line end)
    In Grep, this would be (please note, extra \ for \d and \t ... javascript needs that for some reason):
    ^\\d+\\t(.*)$
    After the script gets the info it needs from a found instance of the above, it replaces that line with "---", to prevent that line from being picked up once again.
    The script with then place the needed page number in it's rightful place on page 2, replacing the XX.
    A while loop is used to repeat the above process until there are no longer any instances of "^\\d+\\t(.*)$" present.
    Not every town runs every issue, so once the script is done, it removes all remaining instance of "XX" on the page 2 TOC.
    FINAL CODE:
    TOC replace
    This script will use grep find/change methods to apply page numbers in
    tocGen to the XX's on page2TOC.
    // define the text frame of generated TOC
        var tocGenFrame  = document.masterSpreads.item("T-tocGen").pages.item(0).textFrames.item(0);
    // udpate generated TOC ... store contents in tocGenStuff
        var tocGenStuff = updateTOCGen();
    // set variable for while loop
    var okGo = "1";
    // while okGo isn't 0
    while(okGo.length!=0)
    // get town info from tocGen
    getCurrentTown();
    // replace XX's with tocGen info
    replaceTown();
    // grep find ... any remaining towns with page numbers in tocGen?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^\\d+\\t(.*)$";
    // set current value of okGo ... with any instances of above grep find in tocGen
    okGo = tocGenFrame.findGrep();   
    // grep find/change all leftover XXs in page2TOC
    app.findGrepPreferences = app.changeGrepPreferences = null;       
    app.findGrepPreferences.findWhat = "^XX\\t";
    app.changeGrepPreferences.changeTo = "\\t";
    app.activeDocument.changeGrep();  
    // clear grep prefs
    app.findGrepPreferences = app.changeGrepPreferences = null;
    //  functions                  //
    function getCurrentTown()
    // grep options   
    app.findChangeGrepOptions.includeLockedLayersForFind = true;
    app.findChangeGrepOptions.includeLockedStoriesForFind = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findChangeGrepOptions.includeFootnotes = true;
    // grep find:  startLine anyDigits tab anyCharacters endLine
          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.findWhat = "^\\d+\\t(.*)$";
    // get grep find results      
    currentGen = tocGenFrame.findGrep();  
    // store grep results content into currentLine
    currentLine = currentGen[0].contents;
    // match to get array of grep found items
    currentMatch = currentGen[0].contents.match("^\\d+\\t(.*)$");
    // second found item is town name, store as currentTown
    currentTown = currentMatch[1];
    // change current line to --- now that data has been grabbed
    // this is because loop will continue as long as the above grep find yields a result
           app.findGrepPreferences.findWhat = "^\\d+\\t"+currentTown+"$";
                  app.changeGrepPreferences.changeTo = "---";
                tocGenFrame.changeGrep(); 
    function replaceTown()
    app.findChangeGrepOptions.includeLockedLayersForFind = true;
    app.findChangeGrepOptions.includeLockedStoriesForFind = true;
    app.findChangeGrepOptions.includeHiddenLayers = true;
    app.findChangeGrepOptions.includeMasterPages = true;
    app.findChangeGrepOptions.includeFootnotes = true;
    // find: XX currentTown .... replace with: currentLine
        app.findGrepPreferences = app.changeGrepPreferences = null;
        app.findGrepPreferences.findWhat = "^XX\\t"+currentTown+" \\(";
        app.changeGrepPreferences.changeTo = currentLine+" \(";
    app.activeDocument.changeGrep();   
    function updateTOCGen()
    //set vars ... toc text frame, toc master pag
        var tocGen  = document.masterSpreads.item("T-tocGen").pages.item(0).textFrames.item(0);
        var tocGenPage  = document.masterSpreads.item("T-tocGen").pages.item(0);
    //SELECT the text frame generatedTOC on the master TOC
        tocGen.select();
    //Update Table of Contents by script menu action:
        app.scriptMenuActions.itemByID(71442).invoke();
    //Deselect selection of text frame holding your TOC:
        app.select(null);
    //store contents of toc text frame in variable
        var tocGenText = tocGen.contents;
    //return contents of tocGen
        return tocGenText;

    Thanks for the reply.
    You are correct but the problem is there are three rows, One row is 100% black, the second is 60% black and the third is 40% black. I want to change the black to blue, the 60% black to an orange and the 40% black to a light shaded blue. In the find/change option you can select the tint you want to find and replace but yea.. does work on table cells.. oddly enough.

  • Help. My daughter changed my iPhone 4 contact names!

    As a joke, my daughter changed all my iPhone contact names to "horse".  Yea, funny!  How do I get them back? I'm worried if I sync with my contacts on my Mac that is will change them to "horse" as well.  Is there an easy way to correct this? It took her two hours to do this behind my back! lol.  Thanks!

    Open iTunes and plug your iPhone into the computer but cancel the sync! very important.  Then click on your iPhone in the left box, then click the info tab, scroll to the bottom of the window to the advance section and select contacts in the check box.  Read the note under this section it will tell you that information on this iPhone will be replace with the information on this computer. Then put your daughter on time out!  LOL...

  • Seen this question before but no answer, how can I change my email address from all caps into a more proper upper-lower style.

    Seen this question before but no answer, how can I change my email address from all caps into a more proper upper-lower style.

    You should be able to change your e-mail address from your provider ... then edit it to meet the Apple requirements.   Unfortunately you've given us no profile details so we can't tell what device you have.

  • Question for scripting gurus: GREP search, change case make Smallcaps

    I have no knowledge of scripting at all, but this question keeps coming up during training sessions: is it possible to (java)script this:
    - Do a GREP search \u\u+
    - Change case to lowercase
    - Apply SmallCaps (or: apply character style)
    this would allow to search for acronyms and change them to smallcaps (or, even better: apply a character style with small caps and tracking)
    I know it is easy for OpenType smallcaps (do a GREP search, change to OT smallcaps) but this doesn't really change case. And some fonts used aren't OT.
    Anyone?
    Would be VERY apreciated!!

    But Harbs is a seasoned scripter who knows he'll get flamed if one of his scripts "just does not work" ;)
    Well, now that you mention it, the script is not really foolproof. It's a quick and dirty script which I threw together very quickly. It's missing any error checking, some of the variables global, and it's not in a private namespace. These are all things which could cause it to "just not work" ;-)
    Here's a more foolproof construct... (and it'll work on the current story if selected, or the whole document if there's no story selected) It will create a new character style if one does not exist and work on character styles within style groups as well. I wrapped the whole script in an anonymous function to give it a unique namespace as well.
    (function()
    if(app.documents.length==0){return}
    var doc=app.documents[0];
    // Change the following to your style name!
    var character_style_name = 'Small Caps';
    try{var range = app.selection[0].parentStory}
    catch (err){var range = doc}
    //comment out next line if you do not want styles.
    var charStyle = GetCharacterStyle(character_style_name,doc);
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat="\\u\\u+";
    var finds=range.findGrep();
    for (var i=0;i<finds.length;i++){
    finds[i].changecase(ChangecaseMode.lowercase);
    //comment out next line if you do not want styles.
    finds[i].applyCharacterStyle (charStyle)
    //uncomment next line if you do not want styles.
    //finds[i].capitalization=Capitalization.smallCaps;
    function GetCharacterStyle(styleName,doc){
    var charStyles=doc.allCharacterStyles;
    for(var i=0;i<charStyles.length;i++){
      if(charStyles[i].name==styleName){
       return charStyles[i];
    return doc.characterStyles.add({name:styleName,capitalization:Capitalization.smallCaps});

  • Get Info "Change All" button doesn't keep the proper "Open With" app

    I have a small but annoying problem that appears in Leopard 10.5.2 (been there since original 10.5.0 install) that I have tried to troubleshoot but can't solve.
    The problem is:
    -With some of my file types, the wrong "Open With" application is displayed when I view a Get Info for that file type. So to fix this, I open a Get Info window on one of those types of files, and choose the PROPER default application in the "Open With" slot. This works, and then the new proper application name now shows in that slot. So then I click the "Change All" button and apply to all files of that file type. I receive the warning that I will be changing ALL files of that type. I choose "continue" because that is what I desire.
    However, once I do that, (click Change All, then Continue button), the old, wrong application name jumps back the Open With slot! So the new, correct application choice doesn't "stick".
    Oddly enough, it sort of DOES work, because if I then re-click in the Open With slot, although the old, the wrong application is back listed again, if I look up above that name, then my actual desired application is listed in a list, and it has the word (Default) beside it.
    So if I do actually now double click any file of that type, then the proper application DOES launch and open the file.
    But why does the Get Info window still display the wrong, non-default application in Open With? And furthermore, this causes all file types of that kind, to display the WRONG icon in any Finder window. They of course display, the icon of what is in the Open With slot list.
    I am having this problem only with two file types and apps. (Cubase and Pro Tools---DAW audio apps). All of my Cubase files display a Pro Tools icon, and show as Open With: "Pro Tools" when of course it should display Open With: Cubase. As stated in the Open With list, Cubase is indeed there among other programs and it has the word (Default) beside it. So it sort of works when launching files. But I still cannot get Cubase to "stick" and stay in Open With after Change All!
    Can anyone offer any tips on what might cause this and what fix is needed?
    Thanks so much in advance!
    Wade

    Well, I tried rebuilding the Launch services with the command listed but still no luck. After having no luck with that and deleting caches, etc....I also, went to my home (user) directory and in Preferences, I deleted the com.apple.launchservices.plist file. I restarted and checked and still the same result.
    Also, I want to emphasize again that the file type I am discussing DOES actually launch with the correct application. (Cubase files in my example).
    But it is just annoying that ALL of my Cubase files display the Pro Tools application icon, and in Get Info they are listed to open with Pro Tools. But they actually do launch Cubase if double clicked.
    And one other VITAL note....if I open Get Info for one of these files, and change the Open With from Pro Tools to Cubase....then that choice DOES "stick" and retain. (if I "don't" also click Change All)
    It's only when I click "Change All" that it DOESN'T stick and the list selection jumps back to Pro Tools. I hope that may offer some clarity.
    Thanks for the tips but I am still back at square one.
    Wade

  • Changing to all caps

    new to pages, so bare with me if this is a stupid question, but i can't find a way to change a string of text to be all text. in micro-soft word there is a button in the toolbar that you click and all the text you have highlighted will turn to all caps. can anyone help?
    thanks,
    ron

    Peggy wrote:
    Use either Format > Font > Capitalization > All Caps or install the free WordService by Devon Technologies.
    I wish to write that in fact, only the use of WordService gives a correct result.
    Using Format > Font > Capitalization > All Caps doesn't change the characters, it just changes the way they are displayed.
    If you copy a group of characters treated with this menu item then paste into TextEdit, you will get lowercase characters.
    Its exactly the same behavior than the use of a format applied to number cells or date_time ones.
    A cell which display 12:34:56 contains in fact 12 janv. 2008 12:34:56 if it was entered the 12 janv. 2008.
    A cell which contain 123.6789 may be displayed as:
    123.6789
    123.679
    123.68
    123.7
    124
    All these displays are perfect.
    With computer we must always remember that what we see is not exactly was is stored.
    It depends of the applied format.
    Back to Word processor, we may apply "All caps", "Small caps" or "Title". The display will change but the contents remains unchanged.
    It's completely different of what we where accustomed to with AppleWorks which changed the contents itself when we asked it to apply the format "UPPERCASE".
    Yvan KOENIG (from FRANCE vendredi 27 juin 2008 21:19:29)

Maybe you are looking for