Shift


Applies To: Windows Server 2003,Windows Vista,Windows Server 2000,Windows Server 2003 with SP2,Windows Server 2003 R2,Windows 7,Windows Server 2008 R2,Windows Server 2008,Windows Server 2003 with SP1,Windows XP

Changes the position of batch parameters in a batch file.

For examples of how to use this command, see Examples.

Syntax


Copy Code

shift [/n <N>]

Parameters

Parameter

Description

/n <N>

Specifies to start shifting at the Nth argument, where N is any value from 0 to 8. Requires command extensions, which are enabled by default.

/?

Displays help at the command prompt.

Remarks

Examples

The following lines from a sample batch file called Mycopy.bat demonstrate how to use shift with any number of batch parameters. In this example, Mycopy.bat copies a list of files to a specific directory. The batch parameters are represented by the directory and file name arguments.


Copy Code

@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

Additional references

Command-Line Syntax Key