how to upcase in the bat file?

  • Thread starter Thread starter ILiya
  • Start date Start date
I

ILiya

For example %cd% returns the current path. How to make what %cd% returns be all in the upper or in lower case?
Thanks
 
For example %cd% returns the current path. How to make what %cd% returns be
all in the upper or in lower case?
Thanks
==========
Unfortunately there is no function in batch files to do this, other
than examining each character in turn an translating it if necessary
(which is very slow and very clumsy). You could use one of the
many freeware tools that float about or you could do it with this
VB Script tool:

#@echo off
#set mode=UCase
#rem set mode=LCase
#call :Upper "%cd%"
#echo new string=%UpperString%
#goto :eof
#
#:Upper
#echo > c:\upper.vbs Set objArgs = WScript.Arguments
#echo >>c:\upper.vbs wscript.echo %mode%(objArgs(0))
#for /F "tokens=*" %%* in ('cscript.exe //nologo c:\upper.vbs %*') do set
UpperString=%%*
#del c:\upper.vbs

Note this:
- You must set the mode to UCase or LCase.
- You must remove all # characters. Their only purpose is to mark the
start of each line, in case they wrap around.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top