The shift command changes the position of replaceable parameters in a batch program.
Availability
Shift is an internal command that is available in the following Microsoft operating systems.
Availability
Shift syntax
Shift examples
MS-DOS 3.00 and above
Windows 95
Windows 98
Windows ME
Windows NT
Windows 2000
Windows XP
Windows Vista
Windows 7
Windows 8
Windows 10
Windows 11
Shift syntax
Windows 2000, XP, and later syntax
Changes the position of replaceable parameters in a batch file.
- Windows 2000, XP, and later syntax.
- Windows ME and earlier syntax.
SHIFT [/n]
With Command Extensions enabled, the SHIFT command supports the /n switch that tells the command to start shifting at the nth argument, where n is between zero and eight. The command below would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 unaffected.
SHIFT /2
Windows ME and earlier syntax
SHIFT
Shift examples
The example below would be done in a batch file; in this example, we are naming the batch file test.bat and it contains the following lines.
@ECHO OFF ECHO - %1 SHIFT ECHO - %1
After creating the example test.bat file shown above, if you were to type the command below at the MS-DOS prompt, it would print “- ONE” and then “- TWO”. This command is often used to work through each of the command extensions or remove command extensions.
TEST ONE TWO
Related information
- See the batch file help page for additional examples and uses of the shift command.
- See our shift definition for further information and related links on this term.