Home NT NT Syntax

Syntax : Wildcards

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 under NT which are best illustrated by example.

e.g. to match the filename BAR.TXT any of the following patterns will match
?AR.TXT
??R.TXT
B?R.???
BA?.TXT
BA??.TXT

However the following will fail to match with BAR.TXT
??AR.TXT
?BAR.TXT
B??AR.TXT

Wildcards will match both Short and Long filenames

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 SFNs follow the usual numeric tails (~1, ~2, ~3, ~4).
Then, from fifth and more files with similar beginning, the short name will have four hex digits right in the middle.
Who would suspect that the pattern "DIC*" will match "diablo1648"?

Wildcards are supported by the following commands:
ATTRIB, CACLS, COPY, DEL, DIR, EXPAND, EXTRACT, FOR, FORFILES, FTP, MOVE, MUNGE, MV, NET (*=Any Drive), PERMS, PRINT, QGREP, REN, ROBOCOPY, ROUTE, TYPE, WHERE, XCACLS, XCOPY

Related
:

FINDSTR
Long and short filename issues



Simon Sheppard
SS64.com