List only files of a particular extension with the DIR command

14

2

On Windows, we can see directory content using the DIR command.

I want to know, how can one see the list of only those files which have particular extension, e.g I want to see list of all .txt files, what command I should run?

Johnydep

Posted 2012-01-26T15:10:59.860

Reputation: 815

Answers

17

Dir supports wildcards, so:

dir *.txt

EBGreen

Posted 2012-01-26T15:10:59.860

Reputation: 7 834

This doesn't quite what the OP wants, see https://stackoverflow.com/questions/2423935

– tubbie – 2018-11-11T10:31:52.543

It does quite a bit more also, try...Dir /? – EBGreen – 2012-01-26T15:19:53.743

i tried but it did not show me * option, rest i know. – Johnydep – 2012-01-26T15:29:01.810

4

dir /S *.txt 

will show files with ".txt" suffix in specified directory and all sub-directories.

Haifeng Li

Posted 2012-01-26T15:10:59.860

Reputation: 141

4

You can list only the filenames without the extra information added with the command
dir /b *.[extension].

A more comprehensive list can be found here .

SpoiledBrat

Posted 2012-01-26T15:10:59.860

Reputation: 41