GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing ss64.com — Shift - reposition command line parameters - Windows CMD SHIFTChange the position of command line arguments passed to a batch file. Syntax
SHIFT [/n]
Key
/n Start at the nth argument, where n is between zero and eight.
You can get the value of any argument using a % followed by its numerical position on the command line. The first item passed is always %1 the second item is always %2 and so on. Only parameters %1 to %9 can be referenced by number, but it is possibly to pass more than 9 arguments. The SHIFT command provides a way of accessing these additional argument values. In addition to allowing a large number of parameters to be read, the SHIFT command is also useful for manipulating optional parameters which may or may not be present. See this StackOverflow answer for an example. SHIFT will not affect the value of %* which holds all the original arguments %1 %2 %3... The argument %0 will initially refer to the path that was used to execute the batch, e.g. MyBatch.cmd if in the current directory or a full path like C:\apps\myBatch.cmd The SHIFT command will not work within parentheses/brackets, so place all your command line arguments in variables before running any FOR commands or other bracketed expressions. Or use the CALL syntax as explained in this forum thread. Drag and Drop
Warning: SHIFT can change the value of %0
Errorlevels
SHIFT is an internal command. If Command Extensions are disabled, the SHIFT command will not support the /n switch. ExamplesDemobatch.cmd The Quick Brown As given %1=The, %2=Quick, %3=Brown Given %1=the, %2=quick, %3=brown, %4=fox “A small key opens big doors” ~ Turkish Proverb Related commandsCALL - Call one batch program from another. Copyright © 1999-2026 SS64.com
Some rights reserved |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |