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

时间:2022-09-13 00:05:40

I'm trying to use the freeware Multiple Find And Replace 1.00 suggested in this question.

我正在尝试使用此问题中建议的免费软件Multiple Find And Replace 1.00。

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

多个查找和替换1.00 http://www.nontube.com/images/screenshot-mfar.png

Unfortunately it requires that I explicitly select each file I'd like it to search.

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

But, it does allow me to load in a text file of the file paths.

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

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

I'd like a text file of paths to all files with extension .php within a certain directory and all its subdirectories (recursive).

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

Does anyone know of a ready-made tool I can use to quickly generate such a list of files?

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

5 个解决方案

#1


4  

You can use built-in DOS commands like so:

您可以使用内置的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

#2


2  

dir /S /B *.php

dir / S / B * .php

#3


1  

If the simple:

如果简单:

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

is not sufficient then Total Commander will certainly do the task. The multi rename tool in Total Commander is excelent.

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

#4


1  

Open a command prompt, cd to the folder you want to find files in and run

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

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

then look in somefile.txt

然后查看somefile.txt

(looks like I lose the race .... !)

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

#5


1  

If you don't mind installing Cygwin, the following one-liner will do the find-and-replace:

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

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

sed also support regular expressions, so the text-to-find can be a regex, and the text-to-replace can contain references to groups fro the pattern text.

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

#1


4  

You can use built-in DOS commands like so:

您可以使用内置的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

#2


2  

dir /S /B *.php

dir / S / B * .php

#3


1  

If the simple:

如果简单:

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

is not sufficient then Total Commander will certainly do the task. The multi rename tool in Total Commander is excelent.

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

#4


1  

Open a command prompt, cd to the folder you want to find files in and run

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

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

then look in somefile.txt

然后查看somefile.txt

(looks like I lose the race .... !)

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

#5


1  

If you don't mind installing Cygwin, the following one-liner will do the find-and-replace:

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

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

sed also support regular expressions, so the text-to-find can be a regex, and the text-to-replace can contain references to groups fro the pattern text.

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