how to convert user input to uppercase

Hi,

how to convert user input (lowercase) to uppercase in the dos batch file ?

echo. 
SET /p user1=Enter username:
SET user2=%user1%V
echo.
echo %user1%
echo.
echo %user2%
echo. 

With Regards

echo "siva"|tr 'a-z' 'A-Z'

Hi,

Thanks that works, further

I want to assign that value to some variable say U1 and want to define new user value by appending 'V' to that value.

For example.
user entered value is db then after using your provided command it shows DB, so

U1=DB (How to assign the "uppercase" output value to U1?)

U2 shoud be as 'DBV' (how to generate the new value as ''DBV" and assign to U2 ?)

With Regards

U1=`echo siva | tr '[a-z]' '[A-Z]'`
U2="${U1}V"

Hi,

U1=`echo siva | tr '[a-z]' '[A-Z]'`
U2="${U1}V"
Assigning value to variable (U1, U2) as shown above is not working in the batch script. How to write the same in batch script ?

With Regards

This link may help you.

Hi,

" tr " command is not working in the batch script.

With Regards

SETLOCAL ENABLEDELAYEDEXPANSION
SET String=Abc
SET String
CALL :UpCase String
SET String
CALL :LoCase String
SET String
ENDLOCAL
GOTO:EOF

:LoCase
:: Subroutine to convert a variable VALUE to all lower case.
:: The argument for this subroutine is the variable NAME.
SET %~1=!%1:A=a!
SET %~1=!%1:B=b!
SET %~1=!%1:C=c!
SET %~1=!%1:D=d!
SET %~1=!%1:E=e!
SET %~1=!%1:F=f!
SET %~1=!%1:G=g!
SET %~1=!%1:H=h!
SET %~1=!%1:I=i!
SET %~1=!%1:J=j!
SET %~1=!%1:K=k!
SET %~1=!%1:L=l!
SET %~1=!%1:M=m!
SET %~1=!%1:N=n!
SET %~1=!%1:O=o!
SET %~1=!%1:P=p!
SET %~1=!%1:Q=q!
SET %~1=!%1:R=r!
SET %~1=!%1:S=s!
SET %~1=!%1:T=t!
SET %~1=!%1:U=u!
SET %~1=!%1:V=v!
SET %~1=!%1:W=w!
SET %~1=!%1:X=x!
SET %~1=!%1:Y=y!
SET %~1=!%1:Z=z!
GOTO:EOF

:UpCase
:: Subroutine to convert a variable VALUE to all upper case.
:: The argument for this subroutine is the variable NAME.
SET %~1=!%1:a=A!
SET %~1=!%1:b=B!
SET %~1=!%1:c=C!
SET %~1=!%1:d=D!
SET %~1=!%1:e=E!
SET %~1=!%1:f=F!
SET %~1=!%1:g=G!
SET %~1=!%1:h=H!
SET %~1=!%1:i=I!
SET %~1=!%1:j=J!
SET %~1=!%1:k=K!
SET %~1=!%1:l=L!
SET %~1=!%1:m=M!
SET %~1=!%1:n=N!
SET %~1=!%1:o=O!
SET %~1=!%1:p=P!
SET %~1=!%1:q=Q!
SET %~1=!%1:r=R!
SET %~1=!%1:s=S!
SET %~1=!%1:t=T!
SET %~1=!%1:u=U!
SET %~1=!%1:v=V!
SET %~1=!%1:w=W!
SET %~1=!%1:x=X!
SET %~1=!%1:y=Y!
SET %~1=!%1:z=Z!
GOTO:EOF