In batch processing of DOS, only 9 command-line parameters from %1 to %9 are supported (%0 is used to represent the command itself). If you want your batch to support more than 9 command-line parameters, you need to use the shift command. Each time the shift command is run, the command-line parameters shift left by one position, that is, %2 becomes %1, %3 becomes %2, and so on. A simple example: You create a batch file, suppose it is named tstshift.bat, and the content is as follows:
@echo off
echo %0
echo %1 %2 %3 %4 %5 %6 %7 %8 %9
echo %1
::1
shift
echo %1
::2
shift
echo %1
::3
shift
echo %1
::4
shift
echo %1
::5
shift
echo %1
::6
shift
echo %1
::7
shift
echo %1
::8
shift
echo %1
::9
shift
echo %1
::10
shift
echo %1
Then run:
tstshift 0 1 2 3 4 5 6 7 8 9 a The running result is as follows:
D:\>tstshift 0 1 2 3 4 5 6 7 8 9 a
tstshift
0 1 2 3 4 5 6 7 8
0
1
2
3
4
5
6
7
8
9
a The above are all the functions supported by the shift command. And the shift function under 2000/xp/2003 has a new /n parameter, which is used to specify starting from the nth parameter for shifting. The Chinese help of the shift command under 2000/xp/2003 is:
D:\>shift /?
Change the position of replaceable parameters in a batch file. SHIFT If command extensions are enabled, the SHIFT command supports the /n command-line switch; this command-line switch tells
The command to shift starting from the nth parameter; n is between zero and eight. For example: SHIFT /2 would shift %3 to %2, shift %4 to %3, and so on; and it does not affect %0 and %1.
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“
这个帖子”和“
这个帖子”并努力遵守,如果可能,请告诉更多的人!