Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows batch command to ignore case sensitivity in variables

I have a set of variables I allow some people I work with to edit. These are True (T) and False (F) values, but I have some people that insist on putting t and f instead of the upper case values respectively.

I use the following workaround code to properly set uppercase values:

IF '%dotnet35%'=='f' set dotnet35=F IF '%dotnet35%'=='t' set dotnet35=T IF '%dotnet40%'=='f' set dotnet40=F IF '%dotnet40%'=='t' set dotnet40=T IF '%regedit%'=='f' set regedit=F IF '%regedit%'=='t' set regedit=T IF '%SSL%'=='f' set SSL=F IF '%SSL%'=='t' set SSL=T 

This is however extremely bulky and it's not easy on the eyes... is there any other way of doing this without using VBS or any other programming language?

like image 376
rud3y Avatar asked Jan 06 '12 14:01

rud3y


People also ask

Are variables case-sensitive batch?

To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I.

What is @echo off batch?

batch-file Echo @Echo off @echo off prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.

Is CMD command case-sensitive?

For the most part MS-DOS, the Windows command line, and most of the commands are not case-sensitive. Unlike case-sensitive command line operating systems, like Linux, commands such as the MS-DOS dir command can be typed as DIR, Dir, or dir.


1 Answers

Read HELP IF : the /I switch, if specified, says to do case insensitive string compares. The /I switch can also be used on the string1==string2 form of IF.

So try IF /I %SSL%==F ...

like image 125
PA. Avatar answered Sep 28 '22 05:09

PA.