SoFunction
Updated on 2025-04-10

Super detailed reference for symbols under CMD DOS


:
① Tag locator, which means that the following string is a tag, can be used as the object of the goto command. For example, a ":begin" tag is defined in a batch file, and you can use the "goto begin" command to go to the ":begin" tag to execute the batch command.
② Separate the variable name and the replaced string relationship in %var:string1=string2%.

|
① The pipe character is to use the output of the previous command as the input of the next command. "dir /a/b |more" can display the information output by the dir command screen by screen.
② The binary operator in set/a represents bitwise or.
③ In the help document, it means that the two switches, options or parameters are selected from one of two.

/
① Indicates that the character (string) after it is the function switch (option) of the command. For example, "dir /s/b/a-d" means different parameters specified by the "dir" command.
② In set/a, division is represented.

>
① Command redirection character, redirects the output result of the previous command to the device behind it, and the content in the device behind it is overwritten. For example, you can use "dir > " to output the result of the "dir" command to the text file "".
② In findstr/r, it indicates the right boundary of the matching word, and needs to be used with escape characters\.

<
① Use the contents of the file that follows it as input to its previous command.
② In findstr/r, it indicates the left boundary of the matching word, and needs to be used with escape characters\.

=
① Assignment symbol, used for assignment of variables. For example, "set a=windows" means assigning the string "windows" to the variable "a".
② In set/a, it represents arithmetic operations, such as "set /a x=5-6*5".

\
① In some cases, this "\" symbol represents the root directory of the current path. For example, if the current directory is under c:\windows\system32, then if you "dir\", it is equivalent to "dir c:\".
② In findstr/r, it represents regular escape characters.

,
① Denotes a splitter for continuous expressions in set /a.
② Split elements in some commands.

.
① When the path is followed or appears separately:
A. represents the current directory.
Two. Represents the previous level directory.
② When appearing in the file name in the path:
The last one. represents the separation of the main file name and the extended file name.

?
① In findstr/r, it means that arbitrary character is matched at this position.
② In the path, it means that any character is wildly assigned at this location.
③ Following / means to obtain the command's help document.

2. Multiple symbols (symbols cannot be separated)

&&
① Connect two commands, and only execute the command after && after the command is successful.

||
① Connect two commands, and execute the command after || when the command before || fails.

>&
① Write the output of one handle to the input of another handle.

<&
① Read input from one handle and write it to the output of another handle.

%%
① Two consecutive % means that the detachment is one % in the pretreatment.
② In batch processing, before the in clause of the for statement, two consecutive % are followed by a character (can be letters, numbers and some specific characters), indicating that a cycle is specified.

Ring or traversing indicator variables.
③ In batch processing, in the for statement, the same string as the indicator variable specified before in is used to refer to this indicator variable.

>>
① Command redirector, append the output result of the command before it to the device behind it.
② The binary operator in set /a indicates the logic shift right.

==
① In the if command, determine whether the elements on both sides are the same.

<<
① The binary operator in set /a indicates the logic shift left.

+=
① Binary operator in set /a. For example, set /a a+=b means assigning the result of a plus b to a.

-=
① Binary operator in set /a. For example, set /a a-=b means assigning the result of subtracting a b to a.

*=
① Binary operator in set /a. For example, set /a a*=b means assigning the result of multiplying a by b to a.

/=
① Binary operator in set /a. For example, set /a a/=b means that the result of dividing a by b is assigned to a.

%=
① Binary operator in set /a. For example, set /a a%=b means assigning the remainder of a divided by b to a.
[Note: You can use set /a a%=b directly on the command line, and you can use set /a a%%%=b in batch processing. 】

^=
① Binary operator in set /a. For example, set /a a"^="b means assigning the result of bitwise difference between a and b to a.
[Note: The quotes here are added to "^=" to prevent ^ from being escaped, the same below. 】

&=
① Binary operator in set /a. For example, set /a a"&="b means assigning the result of bitwise a and b to a.

|=
① Binary operator in set /a. For example, set /a a"|="b means assigning the result of bitwise or of a and b to a.

<<=
① Binary operator in set /a. For example, set /a a"<<="b means assigning the result of bit shifting a bit left to a.

>>=
① Binary operator in set /a. For example, set /a a">>="b means assigning the result of shifting a bit right to b bit to a.

\<
① In the general expression of findstr, the beginning of the word is represented.

\>
① In the general expression of findstr, the end of the word is represented.

3. Double symbol pair (a string must be specified between two symbols)

! !
① When variable delay is enabled, use!! to expand the variable name to represent a reference to the variable value.

' '
① In for/f, it means that the content they contain is executed as a command line and analyzes its output.
② In for/f "usebackq", it means that the strings they contain are analyzed as strings.

( )
① The command contains or has priority delimiter. For example, if the for command needs to use this(), we can also see it in commands such as if, echo, etc.
② In set /a, express expression grouping.

" "
① Delimiter. When defining paths with spaces, "" is often used to enclose the paths, and the "" symbol is also required in some commands.
② In for/f, the contents they contain are analyzed as strings.
③ In for/f "usebackq" means that the content they contain is taken as the file path and the content of their file is analyzed.
④ In other cases, it means that the content is a complete string, and the >, >>, <, &, |, spaces, etc. are no longer escaped.

` `
① In for/f, indicate that the content they contain is executed as a command line and analyzes its output.

% %
① Use two separate % to contain a string to represent the environment variable referenced by this string. For example, a %time% can be extended to the current system time.

[ ]
① In the help document, the switch, option or parameter is optional.
② In findstr /r, it means matching according to the character set specified there.