In tip 8971, I scripted ChgCase.bat to change a string to all upper case or all lower case.
I have re-written 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
Where:
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, NOT %VarName%, that contains the string to be converted.
Example:
set VarName=abc123xyzcall ChgCase U VarName
will convert the string in VarName to ABC123XYZ.
ChgCase.bat contains:
@echo off if \{%2\}==\{\} goto :err if exist "%TEMP%\ChgCase.vbs" goto doit @echo.Dim objArguments, ul, iString>"%TEMP%\ChgCase.vbs" @echo.Set objArguments = Wscript.Arguments>>"%TEMP%\ChgCase.vbs" @echo.ul=objArguments(0)>>"%TEMP%\ChgCase.vbs" @echo.iString=objArguments(1)>>"%TEMP%\ChgCase.vbs" @echo.if UCase(ul) = "U" Then>>"%TEMP%\ChgCase.vbs" @echo. WScript.Echo UCase(iString)>>"%TEMP%\ChgCase.vbs" @echo.ELSE>>"%TEMP%\ChgCase.vbs" @echo. WScript.Echo LCase(iString)>>"%TEMP%\ChgCase.vbs" @echo.End If>>"%TEMP%\ChgCase.vbs" goto doit :err @echo Syntax: ChgCase U^|L VarName goto :EOF :doit if /i \{%1\} EQU \{U\} goto OKul if /i \{%1\} NEQ \{L\} goto err :OKul for /f "Tokens=*" %%a in ('cscript //nologo "%TEMP%\ChgCase.vbs" %1 %%%2%%') do ( set %2=%%a )
0 comments
Hide comments