Wildcards in DOS Commands

Aug 28, 2025

Overview

This lecture covers how to use wildcards (asterisk and question mark) in DOS command prompts to work with groups of files effectively.

Wildcards in DOS

  • Two main wildcards in DOS are the asterisk (*) and the question mark (?).
  • The asterisk (*) represents any number of characters in file names or extensions.
  • The asterisk is placed where unknown or variable parts of a name or extension exist.
  • The question mark (?) stands for a single character at a specific position in a file name or extension.
  • Wildcards can be used in commands like DIR and COPY to target multiple files at once.

Practical Examples

  • DIR *.fil lists all files with the ".fil" extension.
  • DIR T* displays files whose names start with "T".
  • DIR ?est.* matches files with any first character, followed by "est", and any extension.
  • DIR ?est* matches files with any first character, then "est", and any following characters.
  • Using wildcards with the COPY command allows copying multiple files based on pattern matching.
  • Example: COPY ?est.fil folder2 copies all files matching the pattern to folder2.
  • Changing extensions while copying is possible, e.g., copying to ".bak" creates backup files.

Key Terms & Definitions

  • Asterisk (*) — wildcard representing any number of characters in file names/extensions.
  • Question Mark (?) — wildcard representing a single character at a specific position.
  • Wildcard — a symbol used to replace or represent one or more characters in file operations.

Action Items / Next Steps

  • Practice using wildcards in DOS commands like DIR and COPY.
  • Experiment with different file patterns to understand wildcard behavior.