How to? What does ~ do?

samintz

Scott Mintz
May 20, 2008
1,555
26
Solon, OH, USA
I came across a CMD batch file with this syntax:
Code:
if "%~1" == "/?" (
    echo usage: ...
    goto :eof
)

What does %~1 mean as opposed to just %1 ? I tried to test it and got the same results both ways.
 

samintz

Scott Mintz
May 20, 2008
1,555
26
Solon, OH, USA
I found where this is documented in CMD. If you do:
Code:
CMD /c CALL /?
It will show you the substitution of batch parameters syntax.

For those interested:
Code:
%~1         - expands %1 removing any surrounding quotes (")
 

Similar threads