batch parameters: everything after %1

前端 未结 7 1167
离开以前
离开以前 2021-02-03 18:44

Duplicate:

  • Is there a way to indicate the last n parameters in a batch file?
  • how to get batch file parameters from Nth position on?
7条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-03 18:47

    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
    

提交回复
热议问题