The * wildcard will match any sequence of characters (including NULL characters) The ? wildcard will match a single character (or a NULL at the end of a filename)
A few quirks affect the operation of wildcards which are best illustrated
To match the filename BAR.TXT any of the following patterns will match
However the following will fail to match with BAR.TXT
The commands COPY and REN accept two sets of wildcards, there are some subtle differences between how these are treated, see the REN page for details.
The command DIR /X will reveal short filenames - where many similar names exist in the same folder the short file name (SFN) may not be an obvious contraction of the long name. e.g.
DIR /X 2002-05-12 01:12 96 DIABLO~1 diablo1640 2002-05-12 01:12 96 DIABLO~2 diablo1641 2002-05-12 01:12 96 DIABLO~3 diablo1642 2002-05-12 01:12 96 DIABLO~4 diablo1643 2002-05-12 01:12 96 DIE359~1 diablo1644 2002-05-12 01:12 96 DIC49C~1 diablo1648 2002-05-12 01:12 96 DIF2E9~1 diablo1740 2002-05-12 01:12 96 DIE2EF~1 diablo1649
As you can see, the first four short filenames follow the usual numeric tails (~1, ~2,
Then, from fifth and more files with similar beginning, the short names have four hex digits in the middle.
Wildcards are supported by the following commands:
ATTRIB, CACLS, COPY, DEL, DIR, EXPAND, EXTRACT, FOR, FORFILES, FTP, MOVE, MV, NET (*=Any Drive), PERMS, PRINT, QGREP, REN, ROBOCOPY, ROUTE, TYPE, WHERE, XCACLS, XCOPY
There are several contexts where CMD.EXE will parse a string as a numeric expression:
IF comparisons - EQU, NEQ, LSS, LEQ, GEQ, GTR
variable substring expansion - %var:~n,m%
FOR /F "TOKENS=n"
FOR /F "SKIP=n"
FOR /L %%A in (n1 n2 n3)
For many purposes a 4 byte signed integer value ranging from -2,147,483,648 to 2,147,483,647 will suffice, but in the above contexts it is also possible to express the numbers in hexadecimal or octal notation.
e.g. Octal: 00, 07 Hex: 0x00, 0xFF
There are a number of subtle differences (Negative numbers, command, version of Windows) which affect how these numbers are parsed and these are described in the DosTips forum thread Rules for how CMD.EXE parses numbers.
“We usually see only the things we are looking for, so much that we sometimes see them where they are not” ~ Eric Hoffer
REN - Rename files
Long and short filename issues