Excluding files of particular extension using DIR command on windows command line
Solution 1:
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$"
Solution 2:
dir /B | find /V ".txt"
This would list all files and find would filter out anything that doesn't contain ".txt". It's far from perfect, but maybe it's enough :)
Solution 3:
It depends on your command interpreter.
Microsoft's cmd
doesn't have such a facility, as you can see from the other answers where one has to post-process the output of dir
. However, the tool from JP Software's TCC/LE has this feature. It is called a file exclusion range and is used like this for the example in your question:
dir /[!*.exe] *