Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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_Variables_Findstr - Fatal编程技术网

Batch file 从FINDSTR输出到批处理命令中的字符串

Batch file 从FINDSTR输出到批处理命令中的字符串,batch-file,variables,findstr,Batch File,Variables,Findstr,如果有人能在这件事上为我节省一些时间,我将不胜感激。 我有一个Windows批处理文件,我用它来匹配两种不同的文件类型和不同的扩展名,并将结果写入一个文件。 它读取一个文件名表(称为matched_filenames.txt),并为其中的每一行尝试在另外两个表中查找文件名 我有这个代码(在一定程度上有效) 但它会将单独的行写入定位的_matches.txt文件 我真的希望将findstr的结果分配给变量,这样我就可以连接它们,然后将连接的行作为单行写入文件 有人能推荐一种更优雅的方法吗?你有没有

如果有人能在这件事上为我节省一些时间,我将不胜感激。 我有一个Windows批处理文件,我用它来匹配两种不同的文件类型和不同的扩展名,并将结果写入一个文件。 它读取一个文件名表(称为matched_filenames.txt),并为其中的每一行尝试在另外两个表中查找文件名

我有这个代码(在一定程度上有效)

但它会将单独的行写入定位的_matches.txt文件

我真的希望将findstr的结果分配给变量,这样我就可以连接它们,然后将连接的行作为单行写入文件


有人能推荐一种更优雅的方法吗?

你有没有遇到过
findstr/G
选项?与解析附近另一个命令的输出的
for/f
结合使用。不,从未尝试过。我会研究的。谢谢你提供了每个文件的2行,你希望在输出文件中得到什么?
for /f "tokens=*" %%z in (%Ourhome%\matched_filenames.txt) do (
rem -------
rem ------- now (for each line), find the photo name in both the list of raw and list of jpg files
rem -------
findstr /C:"%%z" raw_photos_directory.txt >>located_matches.txt
findstr /C:"%%z" jpg_photos_directory.txt >>located_matches.txt
)