Re: How to UPCASE string in bat files?



"Pegasus (MVP)" <I.can@xxxxxxxxxx> wrote in message news:OXj2WvueIHA.5996@xxxxxxxxxxxxxxxxxxxxxxx

"VanguardLH" <V@xxxxxxxxx> wrote in message news:292dnVhkN-sXtVXanZ2dnUVZ_vumnZ2d@xxxxxxxxxxxxxx
"ILiya" <iliya00@xxxxxxxxx> wrote in message news:eab%23cpqeIHA.4260@xxxxxxxxxxxxxxxxxxxxxxx
For example %cd% returns the current path. How to make what %cd% returns be all in the upper or in lower case?
Thanks



Use character substitution with the 'set' command. Run 'set /?' to see the comments on how to do substitution. Write a subroutine (i.e., a section outside the flow of control using a :label) that you call to do the translation.

@echo off
setlocal
...
echo Original value = %CD%
call UPPER "%CD%"
echo Uppercased value = %var%
...
goto EndBatch <-- (see NOTE)
...
:UPPER
set var=%~1
set %var:a=A%
set %var:b=B%
set %var:c=C%
(repeat for each character)
exit
...
:EndBatch
...

NOTE: Use 'goto :EOF' if you don't have any cleanup at the end of the batch script (might not be needed if you use 'setlocal').

This is just off the top of my head. I haven't tested for correctness. Just providing some hints.

I think you omitted a colon when calling your subroutine, and
some variable names in the subroutine itself. This is probably
what you meant:
@echo on
echo Original value = %CD%
call :UPPER "%CD%"
echo Uppercased value = %var%
goto :eof

:UPPER
set var=%~1
set Var=%var:a=A%
set Var=%var:b=B%
set Var=%var:c=C%



Yep. I didn't bother to waste the time to actually write a batch script to go testing the hints that I provided. As I said, "This is just off the top of my head." For the 'call' command, the colon is needed with the label to differentiate that you are specifying a filename in the 'call' command. As I mentioned with running 'set /?', the OP should also run 'call /?' to get help on that command.

.



Relevant Pages

  • Re: How to UPCASE string in bat files?
    ... be all in the upper or in lower case? ... echo Original value = %CD% ... NOTE: Use 'goto:EOF' if you don't have any cleanup at the end of the ... I think you omitted a colon when calling your subroutine, ...
    (microsoft.public.windowsxp.general)
  • Re: how to upcase in the bat file?
    ... all in the upper or in lower case? ... than examining each character in turn an translating it if necessary ... many freeware tools that float about or you could do it with this ... #echo new string=%UpperString% ...
    (microsoft.public.windowsxp.general)
  • Re: How to UPCASE string in bat files?
    ... How to make what %cd% returns be all in the upper or in lower case? ... Use character substitution with the 'set' command. ... echo Original value = %CD% ... goto EndBatch <-- ...
    (microsoft.public.windowsxp.general)
  • Re: how to send an e-mail --- (a problem!)
    ... Steve Searle wrote: ... $ echo hello | Mail -s test john.black@xxxxxxxxxx ... Mail is soft linked to mail, so the upper case M makes no difference. ... different from "mail" on some system I used in the past, SunOS 4 perhaps. ...
    (Fedora)
  • Re: how to send an e-mail --- (a problem!)
    ... $ echo hello | Mail -s test john.black@xxxxxxxxxx ... Mail is soft linked to mail, so the upper case M makes no difference. ... Because it messes up the order in which people normally read text. ... Why is top-posting a bad thing? ...
    (Fedora)