Jump to content

how to upcase in the bat file?


Recommended Posts

Posted

For example %cd% returns the current path. How to make what %cd% returns be all in the upper or in lower case?

Thanks

  • Replies 1
  • Created
  • Last Reply

Popular Days

Guest Pegasus \(MVP\)
Posted

Re: how to upcase in the bat file?

 

 

"ILiya" <iliya00@yandex.ru> wrote in message

news:%23PbmdrscIHA.1184@TK2MSFTNGP04.phx.gbl...

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.


×
×
  • Create New...