I’d like to check if an argument to a batch file is valid based on a list of strings.
For example:
IF %1 IN validArgument1, validArgument2, validArgument3 SET ARG=%1
This would set ARG to one of the valid arguments only if it matched. Ideally case insensitively.
You may also use the array approach:
In my opinion, this method is clearer and simpler to manage with multiple options. For example, you may create the array of valid arguments this way:
Another possibility is to define a variable for each valid argument:
… and then just check the parameter this way: