Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Upper and Lower case both should be accepted  (Read 3704 times)

0 Members and 1 Guest are viewing this topic.

bholeuday

    Topic Starter


    Starter

    Upper and Lower case both should be accepted
    « on: April 14, 2009, 11:34:26 AM »
    Hi,

    my bat file does not accept the values given by the user in upper case.
    Please guide on below what changes should be done so that
    bat should should accept both lower and upper case values.


    @ECHO off
    :start
    Set /P Ename=Enter Environment Name and then Press Enter^>

    IF %Ename%==wld     GOTO WLD
    IF %Ename%==cmd     GOTO CMD
    IF %Ename%==cfgcent GOTO CFGCENT
    IF %Ename%==ricdb   GOTO RICDB
    echo Hello You Have entered wrong Environment
    pause
    goto start

    macdad-



      Expert

      Thanked: 40
      Re: Upper and Lower case both should be accepted
      « Reply #1 on: April 14, 2009, 11:35:51 AM »
      Before the expression in an If statement you can add the /I switch to tell IF to ignore Case.

      Example:
      Code: [Select]
      If /I '%value%'=='Test' echo Test
      Hope this Helps
      ,Nick(macdad-)
      If you dont know DOS, you dont know Windows...

      Thats why Bill Gates created the Windows NT Family.

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Upper and Lower case both should be accepted
      « Reply #2 on: April 14, 2009, 02:33:43 PM »
      Don't work for me!

      devcom



        Apprentice

        Thanked: 37
        Re: Upper and Lower case both should be accepted
        « Reply #3 on: April 14, 2009, 02:51:54 PM »
        Don't work for me!

        Code: [Select]
        C:\Users\_CORE>if /I 'cat' equ 'cat' echo OK
        OK

        C:\Users\_CORE>if /I 'CAT' equ 'cat' echo OK
        OK

        C:\Users\_CORE>if /I 'CaT' equ 'cAt' echo OK
        OK

        C:\Users\_CORE>if 'CaT' equ 'cAt' echo OK



        How it can't work ?
        Download: Choice.exe

        Dias de verano

        • Guest
        Re: Upper and Lower case both should be accepted
        « Reply #4 on: April 14, 2009, 03:46:15 PM »
        How it can't work ?

        Yeah, right!

        Code: [Select]
        C:\>if /i "GeeK"=="gEEk" echo OK
        OK

        What do you mean, Geek-9PM? You should know better than to give that old "doesn't work" stuff here.


        Geek-9pm


          Mastermind
        • Geek After Dark
        • Thanked: 1026
          • Gekk9pm bnlog
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 10
        Re: Upper and Lower case both should be accepted
        « Reply #5 on: April 15, 2009, 05:34:54 PM »
        Quote
        Code:
        C:\>if /i "GeeK"=="gEEk" echo OK
        DUH, do not work for me.

        macdad-



          Expert

          Thanked: 40
          Re: Upper and Lower case both should be accepted
          « Reply #6 on: April 15, 2009, 05:41:18 PM »
          leave out C:\>  ;)
          If you dont know DOS, you dont know Windows...

          Thats why Bill Gates created the Windows NT Family.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Upper and Lower case both should be accepted
          « Reply #7 on: April 15, 2009, 05:58:10 PM »
          OH!  :o


          macdad-



            Expert

            Thanked: 40
            Re: Upper and Lower case both should be accepted
            « Reply #8 on: April 15, 2009, 08:16:30 PM »
            Learn something everyday  8)
            If you dont know DOS, you dont know Windows...

            Thats why Bill Gates created the Windows NT Family.

            Dias de verano

            • Guest
            Re: Upper and Lower case both should be accepted
            « Reply #9 on: April 16, 2009, 12:10:52 AM »