Hi guys
Is there a way to perform multiple checks in single IF condition using the || or && operators
like example:
my script has to take hostnames which starts with either of these 5 characters : s; S; n; N; 10
What I am asking is can i put something like this
IF "%hostname:~0,1%" EQU "s" || "S" || "n" || "N" || "10" (do x) else (do y)
Multiple checks in IF
Moderator: DosItHelp
-
- Posts: 79
- Joined: 13 Dec 2010 10:32
Re: Multiple checks in IF
I think you would need multiple IF statements. You can eliminate case by using /I. But, a for loop like this can help clean it up.
hope this helps get you on the right track
Code: Select all
for %%a in (s n 10) do IF /I "%%a"=="%var1%" (do X) ELSE (do Y)
hope this helps get you on the right track
Re: Multiple checks in IF
wow ! I thought of for loop but not sure how to put it in
thanks for the help. appreciate it ...
thanks for the help. appreciate it ...