Converting Uppercase to Lowercase

  • Thread starter Thread starter Demis Gonçalves
  • Start date Start date
D

Demis Gonçalves

Is there a way to convert a string like "TEST" to "test"?

TIA,

--
======================================
Demis Gonçalves
IBM Tivoli Consultant
São Paulo - Brazil
Mobile: 55 11 9904-9684
IBM Certified Deployment Professional
Tivoli Enterprise Console V3.8 Network Management
======================================
 
Demis said:
Is there a way to convert a string like "TEST" to "test"?

TIA,
with vbs.vb you may want to try taking a look at LCase()

Dim MyString
MyString = "TEST"
MyString = LCase(MyString)
WScript.Echo(MyString)
 
Ews i need to do that with a BAT file. In Unix it´s easy with the TR
command, but windows seems don´t have this command.

Demis
 
Demis said:
Is there a way to convert a string like "TEST" to "test"?

TIA,
==screen=copy=========================================================
C:\test>Chngcase
'myvar' is initially as follows:
[TEST]

And now that we're done, 'myvar' is as follows:
[test]

C:\test>
==screen=copy=========================================================

::ChngCase.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off & setlocal enableextensions enabledelayedexpansion
set myvar=TEST
echo/'myvar' is initially as follows:
echo/[%myvar%]

Call :ToLower %myVar%
set myvar=%ToLower%

echo/
echo/And now that we're done, 'myvar' is as follows:
echo/[%myvar%]
goto :EOF

:ToUpper String (by val)
set ToUpper=%1
for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
) do set ToUpper=!ToUpper:%%A=%%A!
goto :eof

:ToLower String (by val)
set ToLower=%1
for %%A in (a b c d e f g h i j k l m n o p q r s t u v w x y z
) do set ToLower=!ToLower:%%A=%%A!
goto :eof
::ChngCase.cmd::::::::::::::::::::::::::::::::::::::::::::::::::::::::

HTH
 
my friend.. youll find most things that are easy in unix are nearly
impossible in windows (without third party tools).

i might suggest just abandoning this ship all together and climbing back
onto the unix boat.

i look forward to seeing you there..
 
I work only with unix, now im implementing a Tivoli enviroment in Windows. I
m having a lot of problems with windows. I have worked with unix for 6
years, it´s a real OS.
Tks.
 
ews said:
my friend.. youll find most things that are easy in unix are nearly
impossible in windows (without third party tools).

i might suggest just abandoning this ship all together and climbing back
onto the unix boat.

i look forward to seeing you there..

Your tip shows a lack of experience with cmd.exe. A lot of gnu/
unix tools are ported to win32 cli. But you can't take for granted
their presence, so a workaround like mine may fit better.
 
no doubt.. your solution does exactly what he was trying to do. but lack
of experience with cmd.exe isnt all that huge a shortcoming.

i havent found cmd.exe to be as useful or robust as a cli should be and
therefore avoid it when possible. hence the lack of experience. cygwin
is a good start, but still lacks the umpf of its original environment.
 
I agree with you! cmd.exe is very limited and only users who breath MS
sistems can do what the Mathias did. Im a power user of Unix systemas like
AIX and RedHat linux, only one thing is right in this history, Microsoft
will never have the power of the Unix, who didn´t work with unix thiks it´s
difficult, but after have worked with him passes to love it and hate the MS.
It´s a fact.

Best Regards!
 
Microsoft was traditionally a unix company. They wrote Xenix and as part of a unix unification effort also wrote the Intel version of the REAL Unix (AT&T). MS wrote Dos 2 (they didn't write Dos 1) and were building in Unix concepts into that version. Until Windows NT was released all the programmers wrote on Unix machines and their internal company systems also ran on Unix of course.

Now all they use it for is to virus check their products (on the hope that a unix virus can't work in windows and vice versa)

You also need to remember that Windows itself is case insensitive. So there're is little need to change case.

To build on MT sample

Lcase.vbs

Set Ag = WScript.Arguments
Wscript.echo LCase(Ag(0))

The difference between MT and this is a it reads the command line and it also echos to stdout. Note there are two interpreters cscript and wscript. The first does stdout and the second uses message boxes.

So to get a lowercase string to stdout

cscript Lcase.vbs "string which needs to be enclosed in quotes if it contains spaces"
 
An alternative approach -

@echo off
type nul>"%TEMP%\%~1" 2>nul
for /f "tokens=*" %%c in (
'dir "%TEMP%\%~1" /b /l'
) do (
set lCASE=%%c
)
del "%TEMP%\%~1"2>nul
echo %lCASE%
 
ews said:
my friend.. youll find most things that are easy in unix are nearly
impossible in windows (without third party tools).

i might suggest just abandoning this ship all together and climbing back
onto the unix boat.

Or, alternately, changing your expectations wrt to maintaining a unix way of
thinking in a windows environment - that way lies only madness.

/Al
 
Back
Top