Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file Findstr将数据导出到文本文件_Batch File_Findstr - Fatal编程技术网

Batch file Findstr将数据导出到文本文件

Batch file Findstr将数据导出到文本文件,batch-file,findstr,Batch File,Findstr,我试图制作一个程序,在一堆不同的文本文件中找到一个名称,然后将它在另一个文本文件中找到该名称的文件列表制作成另一个文本文件,供不同的程序拾取和运行 对于我在其中查找名称的每个文件,我都有一堆findstr行,结果需要能够处理在多个不同文件中查找名称的问题 findstr /l /m /i /g:"imput.txt" "info\data\ListOfNames1.txt" >>"results.txt" 姓名列表每行增加1个 我在imput.txt和ListOfNames1.tx

我试图制作一个程序,在一堆不同的文本文件中找到一个名称,然后将它在另一个文本文件中找到该名称的文件列表制作成另一个文本文件,供不同的程序拾取和运行

对于我在其中查找名称的每个文件,我都有一堆
findstr
行,结果需要能够处理在多个不同文件中查找名称的问题

findstr /l /m /i /g:"imput.txt" "info\data\ListOfNames1.txt" >>"results.txt"
姓名列表每行增加1个

我在
imput.txt
ListOfNames1.txt
中有
johnDoe
,但
results.txt
始终为空


提前谢谢

这在当前目录中有效:

findstr /L JohnDoe *.txt >> results.txt
但是我猜你想要results.txt文件中的路径,你想要搜索不同的路径吗

然后,您可以通过管道将其传送到程序,以便像这样使用:

findstr /L JohnDoe *.txt | myprog.exe
findstr /S /G:"names.dat" *.txt >> results.txt
f1.txt:JohnDoe is a person
f2.txt:a person is JohnDoe 
onedown\f3.txt:also has JohnDoe in
对于从当前文件夹进行的递归搜索,您可以使用:

findstr /S /C:"JohnDoe" *.txt >> results.txt
要指定名称文件,可以使用以下内容:

findstr /L JohnDoe *.txt | myprog.exe
findstr /S /G:"names.dat" *.txt >> results.txt
f1.txt:JohnDoe is a person
f2.txt:a person is JohnDoe 
onedown\f3.txt:also has JohnDoe in
您的输出可能如下所示:

findstr /L JohnDoe *.txt | myprog.exe
findstr /S /G:"names.dat" *.txt >> results.txt
f1.txt:JohnDoe is a person
f2.txt:a person is JohnDoe 
onedown\f3.txt:also has JohnDoe in

好的,问题是
ListOfNamesX.txt
在一堆文件夹中,我忘了在文件路径中提到
%CD%
。我想这就是睡个好觉能为你做的。

你的代码看起来不错。你能发一小段
input.txt
ListOfNamesx.txt
吗?我想是的,但看起来很明显,我不敢问。。。请把你的答案标记为正确,这样每个人都知道问题已经解决了。嗯……我该怎么做?(你不能在最初的48小时内标记自己的答案——以防万一有人送来更好的答案)