In tip 6301, we determined if a string consisted of all alphabetic characters (A-Z / a-z).

If your string is all alphabetic, you can use IsUpperCase.bat or IsLowerCase.bat to determine if the string is exclusively upper or lower case.

The syntax for using these tools are:

call isuppercase string answer

or

call islowercase string answer

where string is the environment variable you wish to interrogate and answer is a call directed environment variable that will be set to a Y or a N.

IsUpperCase.bat contains:

@echo off
setlocal
set string=%1
set string=%string:"=%
if \{%2\}<h1><a name="_echo_Syntax_IsUpperCase_string_answer_amp_endlocal_amp_goto_EOF_echo_string_findStr_ABCDEFGHIJKLMNOPQRSTUVWXYZ_gt_nul_endlocal_set_2_N_if_ERRORLEVEL_EQU_1_set_2_Y_pre_b_IsLowerCase_bat_b_contains_pre_echo_off_setlocal_set_string_1_set_string_string_if_2_">\{\} @echo Syntax: IsUpperCase string answer&endlocal&goto :EOF
@echo %string%|findStr "\[^ABCDEFGHIJKLMNOPQRSTUVWXYZ\]">nul
endlocal
set %2=N
if %ERRORLEVEL% EQU 1 set %2=Y</a></h1>
IsLowerCase.bat contains:
@echo off
setlocal
set string=%1
set string=%string:"=%
if \{%2\}\{\} @echo Syntax: IsLowerCase string answer&endlocal&goto :EOF
@echo %string%|findStr "\[^abcdefghijklmnopqrstuvwxyz\]">nul
endlocal
set %2=N
if %ERRORLEVEL% EQU 1 set %2=Y