Lowercase letters to uppercase can be solved by listing methods like set str=%str:a=A%, set str=%str:b=B%..., but this is purely manual work with no skill involved. The following demo code allows you to no longer do the repetitive labor of copy + paste + modify that is unfun when converting lowercase letters to uppercase:
@echo off
:: A little modification of the code can realize uppercase to lowercase
set str1=abcdefghijklmnopqrstuvwxyz
set str2=ABCDEFGHIJKLMNOPQRSTUVWXYZ
:main
cls
set str=
set /p str= Please enter the string (press Enter directly to exit):
if not defined str exit
cls
echo.
echo Before conversion: "%str%"
echo.
for /l %%i in (0,1,25) do (
call set char1=%%str1:~%%i,1%%
call set char2=%%str2:~%%i,1%%
call :change
)
echo ____________________________________________
echo.
echo After conversion: "%str%"
echo.
echo Press any key to carry out the next demonstration...
pause>nul
goto main
:change
call set "str=%%str:%char1%=%char2%%%"
goto :eof
Recent Ratings for This Post
( 2 in total)
Click for details
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
考虑问题复杂化,解决问题简洁化。

