Shift command in Windows
Shift helps to change the position of batch parameters in a batch file.
Shift helps to change the position of batch parameters in a batch file. To better understand how to use this command, see the example below.
Shift command syntax
shift [/ n]
Shift command parameter
Parameters
Describe
/ n
Specifies start conversion at argument N, where N is any value from 0 to 8. This parameter requires command extensions (enabled by default).
/?
Show help at thecommand prompt.
Note the shift command
- Shift command changes the values of batch parameters% 0 to% 9 by copying each of these parameters into a previous parameter, the value of% 1 is copied to% 0, the value of% 2 is copy to% 1, etc.
- If the command extension is enabled, the shift command will support the command line option / n.The / n option will specify the start of the shift process at argument N, where N is any value from 0 to 8. For example, SHIFT / 2 will convert% 3 to% 2,% 4 to% 3, etc. 0 and% 1 will not be affected.Command extension is enabled by default.
- You can use the shift command to create a batch file that can accept more than 10 batch parameters.If you specify more than 10 parameters on the command line, the parameters appear after the tenth (% 9), each time one of them will be converted to% 9.
- The shift command will not affect the batch parameter% *.
- There is no reverse shift command (reverse shift command). After you execute the shift command, you cannot restore the batch parameter (% 0) that existed before the change.
Shift command example
The following command from the sample batch file named Mycopy.bat shows how to use the shift command with any number of batch parameters.In this example, Mycopy.bat copies the list of files to a specific directory. The batch parameters will be represented by the directory and file name arguments.
@echo off
rem MYCOPY.BAT copies any number of files
rem để một thư mục.
rem The câu lệnh dùng một câu lệnh sau:
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
See more:
- How to create disk full BAT file repair Windows 10
- How to use Command Prompt to manage wireless networks on Windows 10?
- Access Windows Remote Desktop via Internet
- Summary of tips to fix slow computer errors on Windows
You should read it
- Instructions for activating Night Shift on iOS 9.3
- Fix Windows + Shift + S shortcut not working on Windows 10
- How to Enable Night Shift on a Mac
- How to Enable Night Shift Mode on iPhone
- How to use the new Night Shift feature on macOS Sierra 10.12.4
- Surf the web more easily with the Shift key
- Can the iPhone's Night Shift mode be damaging to user health?
- 17 shortcuts contain Shift useful in Windows
- How to turn on Night Shift night mode on iOS 11 for iPhone
- How to Shift Gears on a Motorcycle
- How to share photos quickly with Shift Click Image Extractor
- How to Shift a Semi Truck
Maybe you are interested
How to create a to-do list using the applications you are using How to build a CRUD to-do list app and manage its state in React Eisenhower Matrix and To-Do List: Which Time Management Style Is Right For You? How to manage Netflix login devices Top 10 free multiplayer games on web browser How to read special English characters in email: @, #, &, CC, BC, ...