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
- Fsutil transaction command in Windowsthe fsutil transaction command manages the ntfs transactions (ntfs transaction is a windows feature that allows to create, edit, rename, and delete files and folders).
- What is JAVA file? How to open, edit and convert JAVA filesa file with a .java extension is (or sometimes also used in .jav format) is a java source file written in the java programming language.
- [Infographic] Things to know about a hackerhave you ever considered a hacker to be a career? the infographic below will help you know if becoming a hacker is right for you.
- Learn about Sigcheck of Microsoftsigcheck is a command line utility that displays file version numbers, timestamp information and digital signature details, including certificate strings. it also includes an option to check the status of a file on virustotal.
- Synthesis of English abbreviations commonly used on social networksbelow is a summary of commonly used acronyms in english that are often used on social networks, and they can even replace the language of everyday life and their original meaning. please consult.
- Learn about Edge Computing: New boundary and border computing of the Webrecently, the edge computing concept made many people wonder, what technology is it. edge computing is boundary computing, so what does it have to do with cloud computing and what is boundary computing in essence?