Windows CMD: List of files in the dir and subdir directory WITHOUT the specified extensions

I would like to recursively search the directory and find files that DO NOT have a specific extension, or that exactly, that DO NOT have a specific set of extensions.

Sketch: find in “dir” all files without “ext1”, “ext2”, “ext3” and print the results .txt

I tried several hours with DIR and ATTRIB, but, unfortunately, without much success.

Your feedback is much appreciated! Thanks.

+6
command-line list windows file shell
source share
1 answer

Try the following:

dir /b /s /ad | findstr /vi ".ext1$ .ext2$ .ext3$" 

The /ad switch excludes directories, giving you only files. The findstr parameter allows you to search for files for strings, and the /vi switch indicates the exclusion of files containing the following parameter, and the search is case insensitive.

As Joey remarked, $ must indicate the end of the line.

+10
source share

All Articles