27 AND/OR OPERATORS

In this chapter, I’ll discuss what may be the most glaring shortfall in all of Batch. It doesn’t support an and operator, nor is there an or operator. After a brief problem statement, I’ll detail a few techniques to simulate or mimic these two operators, handling both the true and false cases. The and is fairly straightforward, but the or requires more ingenuity.

As is often the case with Batch, you can look at a deficiency with frustration or as an inspiration for creativity. These techniques are a must for any Batch coder because without them, you can’t write even moderately interesting if commands.

The Problem Statement ...

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.