【问题标题】:Windows command line search for exact extension with dirWindows 命令行使用 dir 搜索确切的扩展名
【发布时间】:2011-01-26 07:21:16
【问题描述】:

当我进行搜索时:

dir /b /s *.txt

我得到所有扩展名为 .txt 的文件/文件夹。但是当他们有像.txtx 这样的扩展名时,我也会得到他们。如何搜索确切的扩展名?

【问题讨论】:

    标签: windows command-line dir


    【解决方案1】:

    你可以试试这个

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

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

    dir  /b *.txt | findstr  .txt$
    

    【讨论】:

      【解决方案2】:

      我不知道它为什么会这样,但这是可行的:dir /b /s .txt | findstr /e .txt。丑陋但有效。

      【讨论】:

      • 可能是因为 dir 程序期望文件名是 8.3?很好,它也可以处理其他文件名...
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-21
      • 2012-06-21
      • 2017-09-22
      • 2010-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多