Network Administration: Windows Command Wildcards - dummies

Network Administration: Windows Command Wildcards

Wildcards are one of the most compelling reasons to use the command prompt. With wildcards, you can process all the files that match a particular naming pattern with a single command.

For example, suppose that you have a folder containing 500 files, and you want to delete all the files that contain the letters Y2K and end with the extension .doc, which happens to be 50 files. If you open a My Documents window, you’ll spend ten minutes picking these files out from the list.

From a command window, you can delete them all with the single command Del *Y2K*.doc.

You can use two wildcard characters: An asterisk stands for any number of characters, including zero, and an exclamation point stands for just one character. Thus, !Text.doc would match files with names like aText.doc, xText.doc, and 4Text.doc, but not abcText.doc or just Text.doc. However, *Text.doc would match any of the names mentioned in the previous sentence.

Wildcards work differently in Windows than they did in MS-DOS. In MS-DOS, anything you typed after an asterisk was ignored. Thus, ab*cd.doc was the same as ab*.doc. In Windows, the asterisk wildcard can come before static text, so ab*cd.doc and ab*.doc are not the same.