Search code examples
filterwildcarddos

Find files NOT matching *_abc.*


In dos, when I wanted to get a list of files matching a specific filter, I could use something along the lines of:

  • *.* - Means return everything
  • *.txt - Means return all files with a .txt extension
  • *_abc.* - Means return every file that ends with _abc

My question is, using that dos filter structure, how could I return all files NOT matching *_abc.* (In other words, return all files whos name does NOT end in _abc)?

I don't remember if this is possible and I need this since a company I'm working with is using a very old program that still uses that form of command filtering for selecting files for the program to work on - Also, unfortunately, I can't do it via a batch command... It has to be a single command line statement.

Thanks!!!


Solution

  • Pipe the results of your listing to FINDSTR with an appropriate regex search string and the /V option to filter out matching lines.

    dir /b /a-d * | findstr /v /r "_abc\.[^.]*$"