![]() |
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-17 20:29 |
47,814 topics / 349,907 posts / today 4 new / 48,259 members |
| DOS疑难解答 & 问题讨论 (解答室) » Please help me take a look at this batch file |
| Printable Version 706 / 4 |
| Floor1 oceanwind | Posted 2006-01-31 12:56 |
| 初级用户 Posts 12 Credits 136 | |
|
Here is a batch file. I don't understand it. I don't understand SHIFT or the parameters.
REM MYCOPY.BAT copies any number of REM files to a directory. The command REM is MYCOPY DIR FILES SET TODIR=%1 :ONE SHIFT IF"%1"=" "GOTO TWO COPY %1 %TODIR% GOTO ONE :TWO SET TODIR= ECHO ALL DONE Thanks in advance |
|
| Floor2 lks205 | Posted 2006-01-31 14:30 |
| 初级用户 Posts 32 Credits 86 | |
|
I'm just thinking of learning this. Friend in the post above, could you send me a SHIFT program? I'm trying to study it, thanks.
lks205#163.com (please change # to @) |
|
| Floor3 oceanwind | Posted 2006-01-31 16:29 |
| 初级用户 Posts 12 Credits 136 | |
|
Replied already, thanks
|
|
| Floor4 JonePeng | Posted 2006-01-31 18:19 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
The function of Shift is to move the command-line parameters forward, that is, %2 becomes %3, %2 becomes %1, and so on.
|
|
| Floor5 lks205 | Posted 2006-01-31 20:24 |
| 初级用户 Posts 32 Credits 86 | |
|
SHIFT
Changes the position of replaceable parameters in a batch program. Syntax SHIFT SHIFT─Notes How the SHIFT command works The SHIFT command changes the values of replaceable parameters %0 to %9 by copying each parameter to the previous parameter. That is, the value of %1 is copied to %0, the value of %2 is copied to %1, and so on. This command is useful for batch files that perform the same operation on a series of parameters. :m567 Using more than 10 command-line parameters Using the SHIFT command, a batch file can also receive more than 10 command-line parameters. If the specified command-line parameters exceed 10, then the parameters appearing after the 10th parameter (%9) will in turn be shifted into (%9). Restoring replaceable parameters The SHIFT command is irreversible. Once the SHIFT command has been executed, the first parameter before the SHIFT command (%0) cannot be restored. SHIFT─Example The following batch file MYCOPY.BAT shows how to use the SHIFT command to process any number of command-line parameters and copy a series of files to a specified directory. The parameters used are the directory name followed by a series of file names. @echo off rem MYCOPY.BAT copies any number of files rem to a directory。 rem The command uses the following syntax: rem mycopy dir file1 file2 ... set todir=%1 :getfile shift if "%1"=="" goto end copy %1 %todir% goto getfile :end set todir= echo All done |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |