Bat batch file processing ---- DOS command

EDITORIAL:
This article aims to summarize the backup, to facilitate future inquiries, as is the personal summary, if wrong, please correct me; in addition, most of the content from the Internet, books, and various manuals, should please inform the infringement, immediately delete posts to apologize.

(Usually after we compiled the program, whether it is IAR, Keil compiler, or other compilers will produce some trash, so when we want to generate compiled after these trash to delete, each time into a different folder to delete these things, and sometimes believe it will point the wrong, delete the wrong thing, it is generally the main document in a number of projects which we will see the end of .bat batch file to windows, but found that when we put it to use its own copy over that are not used, waste still exists, so a little common Bat analyze the following commands.)

IAR compiler file processing:
IAR compiler file processing

Keil compiler file processing:
Here Insert Picture Description

Analysis:
1 ,: slash indicates "\", instead of a backslash "/"; Batch Notes generally by the symbol "::" (two colons) rem or in the batch command is not a double slash. notes, she is part of the path of the file or folder in a batch, for example: C: // Windows // System32.

2, rd directory is deleted, del you can delete the specified file or directory.

3, rd parameter description
rd Another wording is rmdir
the RD [/ S] [/ Q] [Drive:] path
RMDIR [/ S] [/ Q] [Drive:] path

/ S: In addition to the directory itself, it will delete all files in the specified directory. To remove a directory tree.
/ Q: Quiet mode does not require confirmation with / S remove a directory tree

4, del command Parameter Description
/ F: force the removal of read-only files.
/ S: delete the specified files from all subdirectories.
/ Q: Quiet mode. When you delete a global wildcard, does not require confirmation.
/ A: according to the attributes of the file you want to delete.
Deletes the specified property or outside the specified properties file, / AR, / AH, / AS, / AA respectively delete read-only, hidden, system, archive files; / AR, / AH, / AS, / AA means to delete In addition to the read-only , files other than the hidden, system, archive.
For example:
. "DEL / AR * *" remove all read-only files in the current directory
means to delete all the files except for system files in the current directory "DEL / AS * *." .
I do not know what the file attributes, then use the del / a can.

5, "* .dep" suffix indicates that all dep files.

6, cd that enter a designated directory folder.

General file deletion instruction:
1, you just want to delete a file, the file path shall use the del / q / f
2, you want to delete all the files in the directory directory, the directory itself remains, you can use the directory path del / q / s / f
3, you want to delete the entire directory, you can use the directory path rd / s / q

About: "for / f" delims = "%% i in ( 'dir Objects \ / ad / b / s') do (if not %% ~ xi == hex (del / s / a / q." %% ~ si "))" this command is, in fact, the equivalent loop plus judgment statement, which can be found in "Objects \" this is the target document, while the ".hex" is what we need to implement the elements, because there is a not in front of him , it is equivalent to the inverse of the (in fact, it does not execute it);
first,
① "for / F" delims = "%% I in" ------- cycle
② "dir Objects \ / ad / b / s "------- display the current directory and subdirectories of all files, the meaning of each parameter can be used dir /? View
③" do (if not %% ~ xi ==. hex (del / s / a / q "%% ~ si") "------- except outside the specified file, delete all files

DOS commands in these windows, just put a text file (the establishment of a notepad), modify and save it as a .bat batch file suffix, and then double-click the file will be executed.

In addition, would like to learn more about the batch can look at this command: Bat command to learn
then,
Keil explanation of each file type can be seen here: illustrate some common file type role and function of the Keil
point IAR here: IAR in eww meaning and purpose of each file, ewp, ewd ···, etc.

Guess you like

Origin blog.csdn.net/qq_42992084/article/details/84350434