English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

what does the command in a batch file "shift" do and whats an example

2007-11-29 03:01:47 · 3 answers · asked by littleguns99 3 in Computers & Internet Software

3 answers

shift /?

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.

2007-11-29 03:04:40 · answer #1 · answered by Anonymous · 1 0

The shift command is used to change the position of a parameter in a batch file. Say you take in 5 parameters when your batch file begins (%1 %2 %3 %4 and %5)

If you did a "shift /2", it would leave parameter 1 alone, elminate parameter 2, and move 3 down to 2 and 4 down to 3, etc.

Suppose you had a batch file called "Count"
The file contains:
Echo off
Echo %1
Shift
Echo %1

You would run the file by typing it name and parameters, such as "count 1 2 3"

When the file runs, it will print the first parameter (in this case a 1).
It would then elimanate the %1 parameter (our 1) and move everything down one so that our 2 becomes %1.
It would then print out the new parameter %1 (our 2)

The output for the program would be:
1
2

2007-11-29 03:13:17 · answer #2 · answered by dewcoons 7 · 1 0

Here you go:

http://www.computerhope.com/shift.htm

wdw

2007-11-29 03:06:11 · answer #3 · answered by Who Dares Wins 7 · 0 0

fedest.com, questions and answers