1

Topic: Check on presence of empty parameters

Hello! Not so I understand command files, but I try to understand. Prompt, how it is possible to make check on presence of empty parameters?
There is a job: to Develop the command file the creating, copying or deleting directory specified in command line, depending on the selected key (the substituted parameter)/n,/c,/d
There is a decision:
if %1 ==/n md %2
if %1 ==/c xcopy/i/e %2 %3
if %1 ==/d rd/s/q%2
Probably something not so... I will be grateful for any help. Thanks.

2

Re: Check on presence of empty parameters

nastena_r_v;
What does "presence of empty parameters" mean?
Missing, you mean?
It is possible, for example, so:

 if "%2" equ "" goto noparam 

By the way, recommend always in IF parameters and condition to quote, differently in the absence of parameter there can be surprises: try  to launch yours without parameters from cmd.

3

Re: Check on presence of empty parameters

alekcvp wrote:

By the way, I recommend always in IF parameters and conditions

Parameters and expected value, certainly.

4

Re: Check on presence of empty parameters

alekcvp wrote:

It is possible, for example, so:

It is undesirable to use for  characters which at least in any place have special value. It is possible on habit to apply them in a difficult construction where this character will be interpreted somehow differently, and  problems for no reason. A double quote in this sense - not so suitable character.

5

Re: Check on presence of empty parameters

In the conditions of batch files double quotes are convenient that values allow to compare to gaps and some other, too special , characters:

 if "% ~1" NEQ "" an option command "% ~1"