in DOS batch files, In an IF statement, is it possible to combine two or more conditions using AND or OR ? I was not able to find any documentation for that
Edit – help if and the MS docs say nothing about using more than one condition in an if.
I guess a workaround for AND would be to do
if COND1 (
if COND2 (
cmd
)
)
but this is exactly what I’m trying to avoid.
No, there is no easier way.
For
andyou can also just chain them without introducing blocks:which frankly isn’t any worse than
However, for
orit gets uglier, indeed:or:
I once saw a batch preprocessor which used C-like syntax for control flow and batch stuff in between and then converted such conditionals into multiple jumps and checks. However, that thing was for DOS batch files and was of little to no use in a Windows environment.