Change all caps to lower letters in batch?

May 5, 2011 at 12:57:14
Specs: Windows XP
I need to have the user type somthing and then all the capital letters will be turned into lower letters.
e.x.
SoMtHiNg
will turn into;
somthing

I also need a code that'll test only a certain letter in a variabal like the first or second or somthing.


See More: Change all caps to lower letters in batch?

Report •


#1
May 6, 2011 at 15:13:37
@echo off
SetLocal EnableDelayedExpansion

set var=SoMtHiNg

echo "!var!" - ^^!var^^! With caps

for %%a in (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) do (
    set var=!var:%%a=%%a!
)

echo "!var!" - ^^!var^^! With caps replaced
echo.

echo substrings:
echo !var:~0,1! - First character
echo !var:~-1! - Last character
echo !var:~2,1! - Third character
echo !var:~1,1! - Second character
echo !var:~-2,1! - Second last character
echo !var:~1! - All but the first chacacter
echo !var:~0,-1! - All but the last character
echo.
echo see "set /?" for more information on substrings.
echo.

pause



Report •

#2
May 7, 2011 at 03:37:51
:: ==========================================
::
:: bbman.bat Sat 07-05-2011 17:32:40.81
@echo off & setLocal enableDELAYedeXpansioN

if not exist lower.com call :sub1
set /p S=string ?
echo.!S! | lower

goto :eof

:sub1

@echo off
if exist #.d del #.d
>> #.d echo E0100 E9 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E01A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E01B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E01C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E01D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E01E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E01F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> #.d echo E0200 00 00 00 00 80 3E 80 00 00 74 1B A0 80 00 32 E4
>> #.d echo E0210 8B F0 C6 84 81 00 00 8D 16 82 00 B0 00 B4 3D CD
>> #.d echo E0220 21 72 3A A3 03 01 8B 1E 03 01 B9 FF 00 8D 16 05
>> #.d echo E0230 01 B4 3F CD 21 72 26 3D 00 00 74 21 50 8B C8 8D
>> #.d echo E0240 36 05 01 8B FE AC 3C 41 7C 06 3C 5A 7F 02 04 20
>> #.d echo E0250 AA E2 F2 59 BB 01 00 B4 40 CD 21 EB C9 CD 20 1A
>> #.d echo E0260 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
>> #.d echo E0270 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
>> #.d echo N lower.com
>> #.d echo RCX
>> #.d echo 0180
>> #.d echo W
>> #.d echo Q

debug < #.d > nul
goto :eof


=====================================
Life is too important to be taken seriously.

M2


Report •

#3
May 7, 2011 at 03:44:50
or...

:: ==========================================
::
:: bbman2.bat Sat 07-05-2011 17:40:32.15
@echo off & setLocal enableDELAYedeXpansioN

set /p S=string ?

set S=!S:A=a!
set S=!S:B=b!
set S=!S:C=c!
:: you type in the rest

echo.!S!


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions


Ask Question