How to? What does ~ do?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

samintz

Scott Mintz
May 20, 2008
1,232
11
Solon, OH, USA
#1
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,232
11
Solon, OH, USA
#2
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 (")