SHIFT

(shift)


更改批处理文件中可替换参数的位置。

 

SHIFT [/n]

 

如果命令扩展名被启用,SHIFT 命令支持/n 命令行开关;该命令行开关告诉

命令从第 n 参数开始移位;n 介于零和八之间。例如:

 

    SHIFT /2

 

会将 %3 移位到 %2,将 %4 移位到 %3,等等;并且不影响 %0 %1

 

★★★★★实例★★★★★:

下面的批处理文件MYCOPY.BAT说明怎样用SHIFT命令处理任意多个命令行参数,将一系列文件拷贝到一个指定的目录。使用的参数是目录名和后面的一系列文件名。

@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


Changes the position of replaceable parameters in a batch file.

 

SHIFT [/n]

 

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 may be between zero and eight.  For example:

 

    SHIFT /2

 

would shift %3 to %2, %4 to %3, etc. and leave %0 and %1 unaffected.