For this purpose, define a macro using DOSKEY
. I excluded directories and ignored case – YMMV. Also, /B
seems like the most reasonable DIR
option for filtering, /D
and /W
being inappropriate for the task, and the long formats /N
(default) and /X
containing, in some cases, additional text after the filename (for symlinks). Check it out on the command line:
DOSKEY FIR=DIR/B/A-D^|FINDSTR /VIE $*
DOSKEY FLIR=DIR/X/A-D^|FINDSTR /VIE $*
FIR
for filtered DIR
, get it? :) And FLIR
for the long version if needed. Then use it like this:
fir .jpg
flir jpg
fir "jpg htm"
The latter is because of how FINDSTR
reads patterns supplied as arguments, as documented in the /?
. Only the first argument is treated as a pattern, additional ones are interpreted as file names, even when running in a pipe.
I prefer FINDSTR
over plain FIND
because it has the funky /E
switch which filters only at the end of the line, which seems preferable when filtering by file extension (but again, YMMV).
The handy SS64 site explains how to set up macros in a TXT
file for permanent reuse. Beware, no caret ^
to escape special characters for macros stored in a text file.
To understand the basics of how macros ("Console aliases") work under the hood, read Eryk Sun's brief comments on SO.