Re: How to UPCASE string in bat files?
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Fri, 29 Feb 2008 16:57:53 +0100
"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%
.
- References:
- How to UPCASE string in bat files?
- From: ILiya
- Re: How to UPCASE string in bat files?
- From: VanguardLH
- How to UPCASE string in bat files?
- Prev by Date: ROBOCOPY -- force prompt before overwrite?
- Next by Date: Re: Newbie problrms with Office 2007.
- Previous by thread: Re: How to UPCASE string in bat files?
- Next by thread: Problem installing SP2
- Index(es):
Relevant Pages
|
|