5. Command 'DIR' and Glob pattern

Glob pattern can be used as parameters of a command.

Example:

- the 'DIR' command lists all files in a directory.
- the 'DIR' command with the parameter *.txt shows only files with the extension '.txt'

Type at the prompt (in my case D:\test>)

DIR
and press 'ENTER'. The output contains -among other things- all the files in the current directory, the entry of the subdirectory 'my Doc' inclusive.

22-01-201611:06<DIR>.
22-01-201611:06<DIR>..
22-01-201611:06<DIR>my Doc
22-01-201611:071file1.txt
22-01-201611:071file2.dat
22-01-201611:071file2.txt
22-01-201611:071file3.txt
23-01-201612:1885pic001.jpg
23-01-201612:18123pic002.jpg
25-01-201619:345.852musicBach.mp3
25-01-2016 19:407.966musicBrahms.mp3

Type at the prompt
DIR *.txt 
and press 'Enter'. The result is a list of all files with only the extension '.txt'

We investigate more Glob patterns and possibilities with the command 'COPY'.

By the way, notice that the 'DIR' command has useful switches, e.g. /OS (Order by Size), /OE (Order by Extension) and /OD (Order by Date). So, the command
DIR /OD
-after pressing 'Enter'- lists all files by date. To learn more about the 'DIR' command, type at the prompt
DIR /?
and press 'Enter'.

Reading notes for this tutorial
  1. The instruction 'Press Enter' will be shortened to [ENTER].
  2. The instructions 'type at the prompt' will be shortened to 'type' and each command will start with the prompt: D:\test>