Windows – Excluding files of particular extension using DIR command on windows command line

command linedirwindowswindows 7

if i want to see e.g. files of a particular extension only using dir listing, i can do that using the command:

DIR *.txt 

And it shows all files with .txt extension.
Now i want to know is there any command with wich i can exclude certain extensions?
For example, i don't want to see any file with extension .exe, how can i do that?

Best Answer

DIR wont allow what you are trying to do. However DIR along with FINDSTR can solve this.

e.g. The following ignores all .txt files in the DIR listing.

dir | findstr /v /i "\.txt$" 
Related Question