Not DIR

Posted on

Apr,25

 at

4:59 pm

by

jimazing

Looking for a command to do sort of the opposite of the DIR command in Windows today, I asked for help from the team and they came through for me!  Here’s what I was trying to do…

DIR *.ini

returns a list of files with the “ini” extension, but what I wanted was a list of files that did not have an “ini” extension.  Unfortunately Windows does not include a DIR flag for not matching a pattern :(

After a few hours, we have a quite elegant solution and a new tool in my toolbox, “findstr”.  Here’s the whole command to retrieve files from a directory that do not have an “ini” extention.

dir /b | findstr -v -i -e “.ini”

Thanks Rob Hoffman and Will Ballance.  I’m glad you are on my team.

One Response to “Not DIR”

  1. […] on the Not Dir command from last Friday… Andrew asked me today if I would help him come up with a way to […]

Leave a Reply