BATCH SCRIPTING// IF CONDITION // Batch Scripting Part -16- IF CONDITION

Опубликовано: 06 Октябрь 2024
на канале: Techno Puffin
672
12

UDEMY : https://www.udemy.com/course/learn-ba...
Title: BATCH SCRIPTING// IF CONDITION // Batch Scripting Part 16 IF CONDITION


In this lesson, you will be learning about IF CONDITION for Batch Script.


IF CONDITION: The first decision-making statement is the ‘if’ statement. The general form of this statement in Batch Script is as follows −


if(condition) do_something


One of the common uses for the ‘if’ statement in Batch Script is for checking variables which are set in Batch Script itself. The evaluation of the ‘if’ statement can be done for both strings and numbers.


Checking Integer Variables
The following example shows how the ‘if’ statement can be used for numbers.


Example


@echo off
SET /A a = 5
SET /A b = 10
SET /A c = %a% + %b%
if %c%==15 echo "The value of variable c is 15"
if %c%==10 echo "The value of variable c is 10"


OUTPUT
"The value of variable c is 15"


Checking String Variables
The following example shows how the ‘if’ statement can be used for strings.


Example


@echo off
SET str1 = String1
SET str2 = String2
if %str1%==String1 echo "The value of variable str1 is correct"
if %str2%==String3 echo "The value of variable str2 is correct"


Output


The above command produces the following output.


"The value of variable str1 is correct"


Note − One key thing to note is that the evaluation in the ‘if’ statement is "case-sensitive”. The same program as above is modified a little as shown in the following example. In the first statement, we have changed the comparison criteria. Because of the different casing, the output of the following program would yield nothing.


@echo off
SET str1 = String1
SET str2 = String2
if %str1%==String1 echo "The value of variable str1 is correct"
if %str2%==String2 echo "The value of variable str2 is correct"


Output


The above command produces the following output.


"The value of variable str2 is correct"
=======================================================


If you have any questions, please post them. Don't forget to comment, like, rate and subscribe


=====================================================


Batch file programming tutorial // CREATE BATCH FILE // Batch Scripting Part-1 --    • Batch file programming tutorial // CR...  


Batch file programming tutorial // Batch Scripting Part-2 - Basic Batch Commands --    • Batch file programming tutorial // Ba...  


Batch file programming tutorial // COPY COMMAND // Batch Scripting Part-3 - COPY Batch Command --    • Batch file programming tutorial // CO...  


Batch file programming tutorial // DEL COMMAND // Batch Scripting Part-4 - DEL Batch Command --    • Batch file programming tutorial // DE...  


Batch file programming tutorial // MOVE COMMAND // Batch Scripting Part-5 - MOVE Batch Command --    • Batch file programming tutorial //MOV...  


Batch file programming tutorial // ATTRIB COMMAND // Batch Scripting Part-6 - ATTRIB Batch Command --    • Batch file programming tutorial // AT...  


Batch file programming tutorial // FIND COMMAND // Batch Scripting Part-7 - FIND Batch Command --    • Batch file programming tutorial // FI...  


Batch file programming tutorial // VARIABLES IN BATCH SCRIPT // Batch Scripting Part- 8 - VARIABLES --    • Batch file programming tutorial // VA...  


DO NOT CLICK // LOCAL AND GLOBAL VARIABLES IN BATCH SCRIPT // Part- 9 - LOCAL AND GLOBAL VARIABLES --    • DO NOT CLICK // LOCAL AND GLOBAL VARI...  


BATCH SCRIPTING // STRINGS IN BATCH SCRIPT // Batch Scripting Part- 10 - STRINGS --    • BATCH SCRIPTING // STRINGS IN BATCH S...  


BATCH SCRIPTING// LEFT, MID AND RIGHT STRINGS// Batch Scripting Part- 11- LEFT, MID AND RIGHT STRING --    • BATCH SCRIPTING// LEFT, MID AND RIGHT...  


REMOVE AND REPLACE IN STRING // Batch Scripting Part 12 REMOVE AND REPLACE IN STRING --    • REMOVE AND REPLACE IN STRING // Batch...  


BATCH SCRIPTING// ARRAYS // Batch Scripting Part 13 ARRAYS --    • BATCH SCRIPTING// ARRAYS // Batch Scr...  


BATCH SCRIPTING// MODIFY AND ITERATE OVER AN ARRAYS // Batch Scripting Part 14 MODIFY AND ITERATE --    • BATCH SCRIPTING// MODIFY AND ITERATE ...  


BATCH SCRIPTING// LENGTH OF AN ARRAY // Batch Scripting Part 15 LENGTH OF AN ARRAY --    • BATCH SCRIPTING// LENGTH OF AN ARRAY ...  
======================================================
Check out other videos


WEAPONS THAT CAN DEFEAT THANOS -- https://www.youtube.com/watch?v=nvlez


MS PAINT TRICK -- https://www.youtube.com/watch?v=4IvBC


Matrix Effect --    • Matrix Rain Best Trick// Create Matri...  


CMD: Wi-Fi Password Hack| Find WiFi Password on Windows 10/8/7/XP --    • Video