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=