开发者

Windows CMD: List files in dir & subdir WITHOUT given extensions

I'd like to recursively search a directory and find files, which have NOT a certain e开发者_如何学Pythonxtension, or precisely, which have NOT a certain set of extensions.

Sketch: find in "dir" all files without "ext1", "ext2", "ext3" and print results to .txt

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

Your consideration is highly regarded! Thanks.


Try this:

dir /b /s /a-d | findstr /vi ".ext1$ .ext2$ .ext3$"

The /a-d switch excludes directories, giving you only files. The findstr parameter lets you search the files for strings, and the /vi switch indicates to exclude files containing the next parameter, the search being case insensitive.

As Joey pointed out, the $ is necessary to indicate end of the line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜