如何创建一个文本文件,其中包含指向给定扩展名的所有文件的路径?

时间:2008-12-05 20:06:56

标签: windows search file

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

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

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

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

C:\one.txt  
C:\two.txt  
C:\somedirectory\three.txt

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

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

5 个答案:

答案 0 :(得分:4)

您可以使用内置的DOS命令:

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

e.g。

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

答案 1 :(得分:2)

dir /S /B *.php

答案 2 :(得分:1)

如果简单:

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

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

答案 3 :(得分:1)

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

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

然后查看somefile.txt

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

答案 4 :(得分:1)

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

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

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