This script goes with that last tip about using “dircmd” with an “/-n” value in Windows’ environment variables. In fact, the script *needs* that tweak to be in place before it’s good for anything.

I made this thing a long time ago and it still (mostly) works in Win7 and 10. You type “no” (no quotes), then give the batch file up to nine extension types to exclude from a dir listing.

E.g. no exe dll ini <- That command, if applied to a directory like c:\windows\system32, will weed EXEs, DLLs, and INIs out of the list. As mentioned, it will do up to 9 exclusions. Why nine is the limit, I don’t know... a hardline coder could probably say for sure. Also, the batch has trouble with extensions that have more than three letters. That’s why it mostly works, but partly doesn’t.

@ECHO OFF

IF “%1”==”” GOTO END

SET EXTENSION1=%1
SET EXTENSION2=%2
SET EXTENSION3=%3
SET EXTENSION4=%4
SET EXTENSION5=%5
SET EXTENSION6=%6
SET EXTENSION7=%7
SET EXTENSION8=%8
SET EXTENSION9=%9

IF “%2”==”” SET EXTENSION2=.
IF “%3”==”” SET EXTENSION3=.
IF “%4”==”” SET EXTENSION4=.
IF “%5”==”” SET EXTENSION5=.
IF “%6”==”” SET EXTENSION6=.
IF “%7”==”” SET EXTENSION7=.
IF “%8”==”” SET EXTENSION8=.
IF “%9”==”” SET EXTENSION9=.

DIR /A-D | FIND /V /I “%EXTENSION1%” | FIND /V /I “%EXTENSION2%” | FIND /V /I “%EXTENSION3%” | FIND /V /I “%EXTENSION4%” | FIND /V /I “%EXTENSION5%” | FIND /V /I “%EXTENSION6%” | FIND /V /I “%EXTENSION7%” | FIND /V /I “%EXTENSION8%” | FIND /V /I “%EXTENSION9%” | MORE
GOTO END


:END
SET EXTENSION1=
SET EXTENSION2=
SET EXTENSION3=
SET EXTENSION4=
SET EXTENSION5=
SET EXTENSION6=
SET EXTENSION7=
SET EXTENSION8=
SET EXTENSION9=