batch parameters: everything after %1

There is a shorter solution (one-liner) utilizing the tokenization capabilities of for loops:

:: all_but_first.bat
echo all: %*
for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b
echo all but first: %ALL_BUT_FIRST%

output:

> all_but_first.bat foo bar baz
all: foo bar baz
all but first: bar baz

Footnote: Yes, this solution has issues. Same as pretty much anything written with batch files. It’s 2021. Use Powershell or literally any other actual scripting language.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)