4. Pattern-matching

The Windows Command Interpreter or Windows shell has a pattern-matching feature that makes operating on large numbers of 'names' easy. Notice that 'names' refer to pathnames, filenames, extensions, directories etc. The wildcard patterns (also called Glob patterns or globby patterns) are defined by two characters: the character * (asterisk, star) and the character ? (question mark). Both have a special meaning to the Windows shell.

* matches zero or more of any characters
? matches any single character

When these characters are found, the shell will try to match these against the 'names', e.g. filenames in a directory.

A few examples:

????.txt will accept all files with extension '.txt' that have filenames of four characters long such as

1234.txt
abcd.txt
A-01.txt

So to match pic001.jpg, pic002.jpg from our example directory, you could use pic00?.jpg or pic???.jpg

To get all the filenames with an undefined name length, you have to use the wildcard *: it will accept all filenames regardless how many characters they have.

*.* refers to all files.
*.txt refers to all files that have the extension '.txt'.
*abc*.txt refers to all files with the extension '.txt' that have the string 'abc' in the filename.

So to match the two example audio files musicBach.mp3 and musicBrahms.mp3, you could use (among others) music*.mp3 or m*.mp3 or *.mp3