Shift command in Windows
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
4.5 ★ | 2 Vote
You should read it
- 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
May be interested
- How to Enable Night Shift Mode on iPhonethis is an article that shows you how to turn on night shift mode on iphone and how to schedule night shift mode to turn on automatically at certain times of the day. night shift mode is a blue light filter that helps prevent circadian rhythm disturbances...
- How to use the new Night Shift feature on macOS Sierra 10.12.4macos 10.12.4 is a new version of the upgraded operating system on macs with some new features, including the night shift feature.
- 10 useful commands in Windows you should knowcommand prompt is used to execute batch files, perform tasks quickly, help you troubleshoot and solve some windows problems when the system crashes. however, not all commands in windows are useful and must be done regularly. with the 10 command lines in the following article it is very useful even if you are not an administrator.
- Instructions to fix the error of pressing shift 2 but not getting @ in a flashare you having trouble pressing shift 2 and not getting @? tipsmake has revealed the secret to help you fix this problem in a jiffy.
- How to use the option equivalent to the 'ls' command in Windowsthe 'ls' command (note ls, not is) is one of the first terminal commands veterans teach to linux beginners.
- The command reg add in Windowsthe reg add command adds new subkeys or entries to the registry.
- Rem command in Windowsthe rem command helps write comments (comments) in a batch file or config.sys.
- Instructions for using Command Promptdeep in windows is a command-line world that is obscure. in this article, we will show you how to solve errors and make your computer more secure.
- Rd command in Windowsthe rd command helps delete a directory
- Surf the web more easily with the Shift keyeach browser has dozens of separate shortcuts to help you surf the web faster and more efficiently, in the article content below, tipsmake.com will send you the utilities brought from the shift key when surfing the web.