batch parameters: everything after %1

前端 未结 7 1100
离开以前
离开以前 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

    You can use SHIFT for this. It removes %1 and shifts all other arguments one lower. This script outputs all the arguments after %2 (so it outputs %3, %4...) until one of them is empty (so it's the last one):

    @echo off
    
    SHIFT
    SHIFT
    
    :loop
    if "%1" == "" goto end
    echo %1
    SHIFT
    goto loop
    
    :end
    

    EDIT: Removed example using %* as this doesn't work - %* always outputs all of the parameters

提交回复
热议问题