4 CONDITIONAL EXECUTION

The if command, which is quite likely common to all programming languages, causes one or more lines of code to be executed only when a condition is true, and a different section of code can be executed only when that condition is false.

The basics are straightforward, but in Batch the conditional clause, or the entity that evaluates to true or false, is quite different from similar clauses in other languages. Most of the compare operators are unique to Batch, and in this chapter you’ll learn the syntax to determine whether a path or file exists and whether a variable is populated. It’s also important to understand ...

Get The Book of Batch Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.