|
SHIFT
Changes the position of batch parameters in a batch file.
Syntax
SHIFT [/n]
/n tells the SHIFT command to start shifting at the nth
argument, where n may be between zero and eight.
The SHIFT command changes the values of the batch parameters
%0 through %9 by copying each parameter into the previous
one. In other words, the value of %1 is copied to %0, the
value of %2 is copied to %1, and so on. This is useful for
writing a batch file that performs the same operation on any
number of parameters.
If Command Extensions are disabled, the SHIFT command will
not support the /n switch.
SHIFT has no affect on the %* batch parameter.
There is no backward shift command. After you carry out the
shift command, you cannot recover the first batch parameter
(%0) that existed before the shift.
Examples
@echo off
rem COPYFILES.BAT copies any number of files
rem to a directory.
rem The command uses the following syntax:
rem copyfiles dir file1 file2 ...
set todir=%1
:getfile
shift
if "%1"=="" goto end
copy %1 %todir%
goto getfile
:end
set todir=
echo All done
Cmd Commands
|