Q. How do I determine if an all alphabetic string is all upper case or all lower case?

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\}

\{\} @echo Syntax: IsUpperCase string answer&endlocal&goto :EOF @echo %string%|findStr "\[^ABCDEFGHIJKLMNOPQRSTUVWXYZ\]">nul endlocal set %2=N if %ERRORLEVEL% EQU 1 set %2=Y

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


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish