Shift command details
Shift is to move all parameters one by one.
Shift/2 is to move all the following parameters forward from the first parameter, but it does not affect the previous parameter position (I .e., it does not affect 1)
Shift/3 is to move all the following parameters forward from the first parameter, but it does not affect the previous parameter position (I .e., it does not affect 1, 2)
And so on ...... ......
Example 1 shift. bat
Batch code
- @ Echo off
- Parameters before echo shift: % 1% 2% 3% 5
- Shift/2
- Echo parameters after second displacement: % 1% 2% 3% 5
- Shift
- Echo parameter after another shift: % 1% 2% 3% 4% 5
- Pause
@ Echo offecho parameters before shift: % 1% 2% 3% 4% 5 shift/2 Echo parameters after second shift: % 1% 2% 3% 4% 5 shiftecho parameters after another shift: % 1% 2% 3% 5 pause
Example 2 call shift. Callshift. bat
Batch code
- @ Echo off
- Call shift. Bat 1 2 3 4 5
@echo offcall shift.bat 1 2 3 4 5
Double-click callshift. bat and the running result is:
Batch code
- Parameters before shift: 1 2 3 4 5
- Parameters after the second displacement: 1 3 4 5
- Parameters after another shift: 3 4 5