This article mainly introduced DOS commonly used several commands and the example usage, relatively simple, is suitable for the novice study
Common DOS commands and syntax
The CD changes the current directory,
Dir lists the file and folder names,
Dir/ad/b refers to the folders listed in the current directory
Echo
ECHO hint message content #解释: output hint information
If you want to turn off the display of the echo command line itself, you need to precede the command line with "@", such as: @echo does not display the Echo
Close the DOS command prompt, type echo off at the DOS prompt, and turn off the display of the DOS prompt so that the screen leaves only the cursor until you type echo on and the prompt will appear again.
Output blank line, which is equivalent to entering a carriage return, ECHO.
It is important to note that in the command line. "There must be no spaces in the middle of the echo, otherwise". "will be output to the screen as a cue message. In addition ". "may use,:;"/[]+, such as any symbol substitution.
In the following example, Echo. The output carriage return, which is turned into a DOS pipe as input to the time command, is equivalent to giving a carriage return after the time command has been executed. Therefore, the system automatically returns to the DOS prompt after the current time is displayed:
C:〉echo.| Time
pause it prompts "Press any key to continue ...", the pause command has no arguments, its command is itself, and when the pause command runs, it interrupts the executed statement. This interrupt is not stopped immediately, just paused, and the following statement continues after any key is pressed. And should be used more than once, in a batch command, you can try multiple pause commands.
I want to customize this hint text and change it to something else. Like "Please press any key to start or end" or directly remove the prompts, keep the pause function, for the following methods can be implemented:
echo Please press any key to start or end
Pause>nul
& nbsp; Explanation: The second sentence function is to remove the hint "press any key to continue ...", the first sentence is the hint you want to output
Copy/xcopy copy files,
/y Does not use the prompt to confirm that you want to overwrite the existing destination file. The
/-y uses a prompt to confirm whether you want to overwrite an existing destination file.
del Delete file,
Rd Delete directory,
/s except the directory itself, also deletes the specified directory All subdirectories and files. Used to delete a directory tree.
/q Quiet mode, which does not require confirmation when deleting a tree with/s .
MkDir and MD are all created directories,
under Windows, create directories and directory trees, and create trees without the need for arguments to create them;
Move srcfile targetfile
&nbs p; move or rename files and directories
ren srcfile targetfile change file names,
Syntax section:
. Represents the current directory as under Linux;
. Also, as in Linux, represents the upper-level directory;
in DOS commands and arguments are case-insensitive, so the command can be Uppercase, can also be lowercase, or it can be a mixed case;
The% number in the batch represents the first few parameters, such as running A.bat a B, A.bat itself is%0, the first argument is%1, the second is%2, and so on.
dos "|" "| |" & "&&" stands for
| The previous command output as input to the following command
| | | | | | | The following command executes when the previous command fails
& the previous command executes followed by the following command
&& Amp The previous command executed successfully before executing the following command
Two% is used to go to variable value
Dos Comment
-------------------if statement use-------------------
If not exist folder1 MD folder2
Explanation: if The Folder1 folder does not exist, the Dolder2 folder is established;
if not exist *.apk goto S2
If exist *.apk goto S1
: S1
@echo F
@echo being unpack, please wait ...
for%%i in (*.apk) doing Java-jar apktool.jar d-f%%i _%%i && move _%%i unpack apk && move%%i original software Backup && @echo%%i unpack complete! The apk file is not found in the
pause
exit
: S2
echo Directory!
Pause
----------------------------The use of the For statement------------------------------
in the cmd window: for%I in (command 1 does Command2
in a batch file: for%%i in (Command1) do Command2
for%%i in (*.apk) do statement a && statement two ;& statement three
explanation: If you want to execute multiple statements in && side by side;
-------------------------- -----------------------------------
dos common software 7-zip.exe,