【问题标题】:How can I make a text file with paths to all my files of a given extension?如何制作一个包含给定扩展名的所有文件路径的文本文件?
【发布时间】:2008-12-05 20:06:56
【问题描述】:

我正在尝试使用this question 中建议的免费软件Multiple Find And Replace 1.00

Multiple Find And Replace 1.00 http://www.nontube.com/images/screenshot-mfar.png

不幸的是,它要求我明确选择我希望它搜索的每个文件。

但是,它确实允许我加载文件路径的文本文件。

C:\one.txt
C:\两个.txt
C:\somedirectory\three.txt

我想要一个文本文件,其中包含某个目录及其所有子目录(递归)中所有扩展名为 .php 的文件的路径。

有谁知道我可以用来快速生成这样一个文件列表的现成工具吗?

【问题讨论】:

    标签: windows search file


    【解决方案1】:

    你可以像这样使用内置的 DOS 命令:

    cd /d "[base-directory]" && dir /s /b *.php > [list file]
    

    例如

    cd /d "c:\my files" && dir /s /b *.php > c:\list.txt
    

    【讨论】:

      【解决方案2】:

      dir /S /B *.php

      【讨论】:

        【解决方案3】:

        如果简单的话:

        dir /S /B *.php > output.txt
        

        还不够,那么Total Commander 肯定会完成任务。 Total Commander 中的多重重命名工具非常棒。

        【讨论】:

          【解决方案4】:

          打开命令提示符,cd 到要在其中查找文件的文件夹并运行

          dir *.html /B /S > somefile.txt
          

          然后查看 somefile.txt

          (看起来我输掉了比赛......!)

          【讨论】:

            【解决方案5】:

            如果您不介意安装Cygwin,以下单行代码将执行查找和替换:

            find basedir -name \*.php -exec sed -i 's/text-to-find/text-to-replace/g' '{}' '+'
            

            sed 也支持正则表达式,因此 text-to-find 可以是正则表达式,而 text-to-replace 可以包含对模式文本组的引用。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2019-09-30
              • 2014-07-14
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多