开发者

Windows command line search for exact extension with dir

开发者 https://www.devze.com 2022-12-22 09:48 出处:网络
When I do a search: dir /b /s 开发者_如何学JAVA*.txt I get all files/folders with the extension .txt. But I also get them when they have an extension like .txtx. How can I search for the exact exte

When I do a search:

dir /b /s 开发者_如何学JAVA*.txt

I get all files/folders with the extension .txt. But I also get them when they have an extension like .txtx. How can I search for the exact extension?


you can try this

dir  /s /b *.txt | findstr /v .txt.

or

dir  /s /b *.txt | findstr /e .txt

or

dir  /b *.txt | findstr  .txt$


I can't figure out why it behaves like this, but this works: dir /b /s .txt | findstr /e .txt. Ugly but works.


dir C:\XML /s /b | findstr /e .xml > C:\XML\list.txt

this works for me, just change the .xml extension to .txt

0

精彩评论

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