Hopefully "ScriptingTipsAndTricks" helps you with your batch file or vbscript scripting :-)
[Bottom][Contents][Prev]: Batch File Details - Get Name and Directory of the Batch File[Next]: CheckForMissingDirectoryUpdateDescEnvVarIfSo.cmd.txt -
\->Batch Files->Case conversion - to LOWER and UPPER case

Case conversion [to LOWER and UPPER case].cmd

This example uses string replacement to convert all 26 letters from lower to upper case or via versa.

[anchor]

The Code for: "Case conversion [to LOWER and UPPER case].cmd"

This is the example, a shortcut was installed to this code :

@echo off
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
:: $Header:   C:/DBAREIS/Projects.PVCS/Win32/ScriptingTipsAndTricks/EXAMPLE[cmd].Case conversion [to LOWER and UPPER case].cmd.pvcs   1.0   29 Jun 2014 12:51:20   USER "Dennis"  $
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

set SomeString=TheRainInSpain
    echo SomeString(BEFORE) = %SomeString%
         call :ToLowerCase "SomeString"
    echo SomeString(after)  = %SomeString%
         call :ToUpperCase "SomeString"
    echo SomeString(AFTER)  = %SomeString%
goto :EOF



::---------------------------------------------------------------
:ToLowerCase
::---------------------------------------------------------------
    set  TLC_NAME=%~1
    set TLC_VALUE=!%TLC_NAME%!
    if "%TLC_VALUE%" == "" goto :EOF
    set TLC_VALUE=%TLC_VALUE:A=a%
    set TLC_VALUE=%TLC_VALUE:B=b%
    set TLC_VALUE=%TLC_VALUE:C=c%
    set TLC_VALUE=%TLC_VALUE:D=d%
    set TLC_VALUE=%TLC_VALUE:E=e%
    set TLC_VALUE=%TLC_VALUE:F=f%
    set TLC_VALUE=%TLC_VALUE:G=g%
    set TLC_VALUE=%TLC_VALUE:H=h%
    set TLC_VALUE=%TLC_VALUE:I=i%
    set TLC_VALUE=%TLC_VALUE:J=j%
    set TLC_VALUE=%TLC_VALUE:K=k%
    set TLC_VALUE=%TLC_VALUE:L=l%
    set TLC_VALUE=%TLC_VALUE:M=m%
    set TLC_VALUE=%TLC_VALUE:N=n%
    set TLC_VALUE=%TLC_VALUE:O=o%
    set TLC_VALUE=%TLC_VALUE:P=p%
    set TLC_VALUE=%TLC_VALUE:Q=q%
    set TLC_VALUE=%TLC_VALUE:R=r%
    set TLC_VALUE=%TLC_VALUE:S=s%
    set TLC_VALUE=%TLC_VALUE:T=t%
    set TLC_VALUE=%TLC_VALUE:U=u%
    set TLC_VALUE=%TLC_VALUE:V=v%
    set TLC_VALUE=%TLC_VALUE:W=w%
    set TLC_VALUE=%TLC_VALUE:X=x%
    set TLC_VALUE=%TLC_VALUE:Y=y%
    set TLC_VALUE=%TLC_VALUE:Z=z%
    set %TLC_NAME%=%TLC_VALUE%
    goto :EOF


::---------------------------------------------------------------
:ToUpperCase
::---------------------------------------------------------------
    set  TLC_NAME=%~1
    set TLC_VALUE=!%TLC_NAME%!
    if "%TLC_VALUE%" == "" goto :EOF
    set TLC_VALUE=%TLC_VALUE:a=A%
    set TLC_VALUE=%TLC_VALUE:b=B%
    set TLC_VALUE=%TLC_VALUE:c=C%
    set TLC_VALUE=%TLC_VALUE:d=D%
    set TLC_VALUE=%TLC_VALUE:e=E%
    set TLC_VALUE=%TLC_VALUE:f=F%
    set TLC_VALUE=%TLC_VALUE:g=G%
    set TLC_VALUE=%TLC_VALUE:h=H%
    set TLC_VALUE=%TLC_VALUE:i=I%
    set TLC_VALUE=%TLC_VALUE:j=J%
    set TLC_VALUE=%TLC_VALUE:k=K%
    set TLC_VALUE=%TLC_VALUE:l=L%
    set TLC_VALUE=%TLC_VALUE:m=M%
    set TLC_VALUE=%TLC_VALUE:n=N%
    set TLC_VALUE=%TLC_VALUE:o=O%
    set TLC_VALUE=%TLC_VALUE:p=P%
    set TLC_VALUE=%TLC_VALUE:q=Q%
    set TLC_VALUE=%TLC_VALUE:r=R%
    set TLC_VALUE=%TLC_VALUE:s=S%
    set TLC_VALUE=%TLC_VALUE:t=T%
    set TLC_VALUE=%TLC_VALUE:u=U%
    set TLC_VALUE=%TLC_VALUE:v=V%
    set TLC_VALUE=%TLC_VALUE:w=W%
    set TLC_VALUE=%TLC_VALUE:x=X%
    set TLC_VALUE=%TLC_VALUE:y=Y%
    set TLC_VALUE=%TLC_VALUE:z=Z%
    set %TLC_NAME%=%TLC_VALUE%
    goto :EOF

Please note that that I am not trying to show how great I am by producing batch files 9,000 characters long on one line that no one will understand or be able to debug when they go wrong. I am going out of my way to comment the code and make it verbose so beginners and advanced users will both benefit. I don't claim to be an expert that knows everything, if I'm wrong or make a mistake then please contact me and let me know :-)


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Batch File Details - Get Name and Directory of the Batch File[Next]: CheckForMissingDirectoryUpdateDescEnvVarIfSo.cmd.txt -


ScriptingTipsAndTricks© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday September 07 2014 at 12:50pm
Visit ScriptingTipsAndTricks's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.