Microsoft DOS shift command
Quick links
About shift
Availability
Syntax
Examples
Changes the position of replaceable parameters in a batch program.
The shift command is an internal command that is available in the below Microsoft operating systems.
MS-DOS 3.00 and above
Windows 95
Windows 98
Windows ME
Windows NT
Windows 2000
Windows XP
Windows Vista
Windows 7
Windows 95, Windows 98, and Windows ME syntax
Changes the position of replaceable parameters in a batch file.
SHIFT
Windows 2000 and Windows XP syntax
Changes the position of replaceable parameters in a batch file.
SHIFT [/n]
If Command Extensions are enabled the SHIFT command supports the /n switch that tells the command to start shifting at the nth argument, where n may be between zero and eight. For example:
SHIFT /2
would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 unaffected.
The below example would be done in a batch file; in this example we are naming the batch file test.bat and it contains the below lines.
@ECHO OFF
ECHO - %1
SHIFT
ECHO - %1
After creating the above example test.bat file, if you were to type the below command at the MS-DOS prompt, it would print "- ONE" and then "- TWO"; this command is commonly used to work through each of the command extensions or remove command extensions.
TEST ONE TWO
See batch file page for additional examples and uses of the choice command.
