Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the commonly used dos commands and syntax

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about common dos commands and grammars. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Common dos commands and syntax

Cd changes the current directory

Dir lists file and folder names

Dir / ad / b refers to the folders listed in the current directory

Echo

ECHO prompt message content # explanation: output prompt message

If you want to turn off the display of the "ECHO" command line itself, you need to add "@" before the command line. For example, @ echo does not display the echo of this line.

By closing the DOS command prompt and typing ECHO OFF at the DOS prompt, you can turn off the display of the DOS prompt and leave only the cursor on the screen until you type ECHO ON. The prompt will not reappear.

Output blank line, that is, equivalent to entering an enter, ECHO.

It is worth noting that the "." on the command line should be followed by ECHO without a space, otherwise "." will be output to the screen as a prompt. In addition, "." can be replaced with any symbol such as,:; / [\] +.

In the following example, the carriage return of the ECHO. Output is turned through the DOS pipeline as the input of the TIME command, which is equivalent to giving a carriage return after the TIME command is executed. So when executing, the system automatically returns to the DOS prompt state after the current time is displayed:

C: > ECHO. | TIME

Pause it will prompt "Please press any key to continue." the pause command does not have any parameters, its command is itself, and when the pause command runs, it interrupts the executed statement. The interrupt does not stop immediately, it just pauses, and the following statement continues after pressing any key. And you should be able to use it more than once, you can try to use multiple pause commands in one batch command.

I want to customize this prompt text and change it to something else. Such as "Please press any key to start or end" or delete the prompt directly, and retain the pause function, which can be achieved in the following ways:

Echo, please press any key to start or end

Pause > nul

Explanation: the function of the second sentence is to remove the prompt "Please press any key to continue." the first sentence is the prompt you want to output.

Copy / xcopy copy file

/ Y does not use prompts to confirm whether to overwrite the existing target file.

/-Y use the prompt to confirm whether you want to overwrite the existing target file.

Del deletes a file

Rd delete directory

/ s in addition to the directory itself, all subdirectories and files under the specified directory will be deleted. Used to delete the directory tree.

/ Q quiet mode, no confirmation is required when deleting the directory tree with / s.

Both mkdir and md create directories

Under windows, create a directory and a directory tree. When you create a directory tree, you can create it without adding parameters.

Move srcfile targetfile

Move or rename files and directories

Ren srcfile targetfile changes the file name

Grammar part:

. Represents the current directory as under linux

.. It also represents a higher-level directory as under linux.

Under dos, commands and parameters are not case-sensitive, so commands can be uppercase, lowercase, or mixed case.

In a batch, the% number represents the number of parameters, such as running a.bat a b, a.bat itself is 0, the first parameter an is 1, the second is 2, and so on.

In dos, "|" | | "&" represents respectively.

| | the output of the previous command is used as the input of the following command |

| execute the following command only when the previous command fails to execute |

& the previous command is executed followed by the following command

& & the previous command was executed successfully before the following command was executed.

Two% is used to remove the value of the variable

Comments under dos

-the use of if statements-

If not exist folder1 md folder2

Explanation: if the folder1 folder does not exist, create a dolder2 folder

If not exist * .apk goto S2

If exist * .apk goto S1

: s1

@ echo off

@ echo is unpacking, please wait a moment.

For% I in (* .apk) do java-jar apktool.jar d-f% I _% I & & move _%% I unpacked apk & & move% I original software backup & & @ echo% I unpacked complete!

Pause

Exit

: s2

No apk files were found in the echo directory!

Pause

-- use of for statements--

In the cmd window: for% I in (command1) do command2

In batch file: for% I in (command1) do command2

For% I in (* .apk) do statement one & & statement two & statement three

Explanation: if multiple statements are to be executed in for, use & & juxtaposed

Thank you for reading! This is the end of this article on "what are the commonly used dos commands and grammars?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report