In tip 6301, I determined if a string is all alphabetic or all numeric. In tip 6302, I determined if an all alphabetic string is all upper case or all lower case.

NOTE: See Another way to change the case of string to all upper case or all lower case?

I have scripted ChgCase.bat to change a string to all upper case or all lower case.

The syntax for using ChgCase.bat is:

call ChgCase U|L VarName


U changes the string in VarName to upper case.
L changes the string in VarName to lower case.

VarName is the name of the variable that contains the string to be converted.

Sample Usage:

Update all users displayName attributes so that the first character in each name segment is upper case and the remaining characters are lower case:
@echo off
set filter="(&(objectCategory=Person)(objectClass=User))"
set qry=DSQUERY * domainroot -filter %filter% -attr distinguishedName displayName -L -limit 0
for /f "Tokens=1*" %%a in ('%qry%') do (
set attr=%%a
set data=%%b
call :doit1
goto :EOF
if "%attr%" EQU "distinguishedName:" set userDN=%data%&goto :EOF
if "%data%" EQU "" goto :EOF
call echo %data%|FIND "=">nul
call :doit2 %data%
if "%data%" EQU "%name:~1%" goto :EOF
DSMOD user "%userDN%" -Display "%name:~1%"
goto :EOF
set name=
if \{%1\}

\{\} goto :EOF
set s=%1
set v1=%s:~0,1%
set vx=%s:~1%
call ChgCase U v1
call ChgCase L vx
set name=%name% %v1%%vx%
goto doit3

ChgCase.bat contains:
@echo off
If \{%2\}\{\} goto :err
:: Test for nul value and exit
for /f "Tokens=*" %%c in ('@echo %%%2%%') do if \{%%c\}

\{%%%2%%\} goto :EOF
If /i \{%1\}

\{U\} goto UCase
If /i \{%1\}==\{L\} goto LCase
@echo Syntax: ChgCase U^|L VarName
goto :EOF
for %%c in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do call set %2=%%%2:%%c=%%c%%
goto :EOF
for %%c in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do call set %2=%%%2:%%c=%%c%%
uppercase lowercase