Código:
setlocal enabledelayedexpansion
:main
set "string="
set /p "string=string: "
if not defined string goto main
set "output="
set "count=0"
:loop
if "!string:~%count%,1!" neq "" (
set "char=!string:~%count%,1!"
if "!char!" equ "A" set "output=!output!0"
if "!char!" equ "B" set "output=!output!1"
if "!char!" equ "C" set "output=!output!2"
if "!char!" equ "D" set "output=!output!3"
if "!char!" equ "E" set "output=!output!4"
if "!char!" equ "a" set "output=!output!5"
if "!char!" equ "b" set "output=!output!6"
if "!char!" equ "c" set "output=!output!7"
if "!char!" equ "d" set "output=!output!8"
if "!char!" equ "e" set "output=!output!9"
set /a "count+=1"
goto loop
)
echo output: !output!
goto main
Código:
string: ABCDEabcde
output: 0123456789
Generosidad de Matt