简体   繁体   English

Windows批量比较文件

[英]Windows batch compare files

I have this code, that will compare 4 text files N1.txt N2.txt etc. with out.txt. 我有这段代码,它将比较4个文本文件N1.txt N2.txt等与out.txt。

set A=4
for /L %%r in (1,1,%A%) do (
   findstr /vxg:N%%r.txt out.txt>>MissingValues.txt
   for /f %%a in ('^<MissingValues.txt find /v /c ""') do echo %%a differences
)

If i run the part inside the for loop alone, it works fine. 如果我仅在for循环中运行该部分,则效果很好。 When i add the for loop, i am just getting the same values inside the text file, and not only the missing values. 当我添加for循环时,我只是在文本文件中获得了相同的值,而不仅仅是缺少的值。 What is wrong with the code ? 代码有什么问题?

Thanks 谢谢

I found a code that works for my files, it's a bit slow but works fine for my files. 我找到了一个适用于我的文件的代码,虽然有点慢,但适用于我的文件。

@echo off

set A=4
for /L %%r in (1,1,%A%) do (
for /f "delims=" %%a in (out.txt) do (
   find "%%a" <"IMSI%%r.txt" || >>result.txt echo %%a
 )
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM