I’m trying to add some optional paramters to a batch file but am having trouble because the SHIFT
command does not affect the all-arguments variable %*
.
Does anyone know how I can allow for optional batch-file arguments if I have to use %*
?
For example, a simple example that merely prints the arguments to the screen with and without a new-line, using an optional argument to determine which:
@echo off
if (%1)==() goto usage
if (%1)==(/n) goto noeol
goto eol
:eol
echo %*
goto :eof
:noeol
shift
call showline %*
goto :eof
:usage
echo Prints text to the screen
echo > %0 [/n] TEXT
echo /n to NOT print a new-line at the end of the text
goto :eof