Forrest logo
back to the if tool

if:tldr:e8cf6

if: Check whether two strings are equal without respecting letter case.
$ if /i %${variable}% == ${string} (${echo Condition is true})
try on your machine

This command is an example of a conditional statement written in a batch script (or Windows command prompt). Let's break it down:

  • if: This is the keyword used to start a conditional statement.
  • /i: This is an optional flag used to perform a case-insensitive comparison.
  • %${variable}%: This is a variable placeholder (represented by ${variable}) within percent signs (%). In the actual code, the variable name should be placed in between the percent signs, e.g., %variable%. The value of this variable will be used for comparison.
  • ==: This is the comparison operator used to check if two values are equal.
  • ${string}: This is another placeholder for a specific value (represented by ${string}). In the code, the actual string value should replace ${string}.
  • (${echo Condition is true}): This is a command that gets executed only if the condition is true. In this case, it is an echo command followed by the message "Condition is true". The parentheses () are used to group the commands.

So, when this command runs, it checks if the value of the variable (referenced by %${variable}%) equals the specified string (${string}). If the values are the same, it will execute the command within parentheses, which in this case prints "Condition is true" using the echo command.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the if tool