WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Strings

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Capitalize Proper Name


Is there a function that will normalize a proper name (i.e., capitalize the first letter and lower case the remaining) short of stepping thru the string letter-by-letter? I am working on a script to process file names that contain a person's name which may be upper, lower or a combination of cases and I need to create a variable that follows the "normal" capitalization rules.

Any help will be greatly appreciated.

Answer:


#DefineFunction NameCase(OldName)
  Count = ItemCount(OldName," ")
  NewName = ""
  for x = 1 to Count
    N = ItemExtract(x,OldName," ")
    N = StrCat(StrUpper(StrSub(N,1,1)),StrLower(StrSub(N,2,-1)))
    NewName = ItemInsert(N,-1,NewName," ")
  next
  return NewName
#EndFunction


Article ID:   W16721
File Created: 2005:02:18:12:22:02
Last Updated: 2005:02:18:12:22:02