![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-10 16:57 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] Please tell me the usage of the shift batch command? |
| Printable Version 4,199 / 3 |
| Floor1 doslr | Posted 2004-11-08 00:00 |
| 初级用户 Posts 27 Credits 168 | |
|
I really don't understand the usage of the shift command??
Can any expert teach me how the shift command is used? Finally, can you attach an example. Thanks! |
|
| Floor2 autoit | Posted 2004-11-09 00:00 |
| 系统支持 Posts 339 Credits 904 From 厦门 | |
|
更改批处理文件中可替换参数的位置。SHIFT 如果启用了命令扩展,SHIFT命令支持/n开关,该开关告诉命令从第n个参数开始移位,其中n可以在0到8之间。例如:SHIFT /2会将%3移到%2,%4移到%3,等等,并且不影响%0和%1。
The SHIFT command changes the position of replaceable parameters in a batch file. SHIFT If Command Extensions are enabled, the SHIFT command supports the /n switch, which tells the command to start shifting at the nth argument, where n can be between 0 and 8. For example: SHIFT /2 would shift %3 to %2, %4 to %3, etc., and leave %0 and %1 unaffected. |
|
| Floor3 Climbing | Posted 2004-11-10 00:00 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
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. |
|
| Floor4 doslr | Posted 2004-11-12 00:00 |
| 初级用户 Posts 27 Credits 168 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |