使用批处理命令比较文件夹和子文件夹文件 [英] Comparing Folders and Subfolders files using batch command

查看:305
本文介绍了使用批处理命令比较文件夹和子文件夹文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文件夹.我想比较这些文件夹中的文件.根文件夹中有一些子文件夹.这些子文件夹还包含一些文件.我也想在子文件夹中比较这些文件.为此,我试图编写一个批处理文件.任何一种解决方案都会对我有很大帮助

I have two folders. I want to compare the files inside these folders.There are some subfolders in root folders. These sub folders are also containing some files. I want to compare these files in subfolder also. For that I am trying to write a batch file. Any kind of solution will help me a lot

推荐答案

我根本不会使用批处理文件来完成此任务. BeyondCompare 正是在这里做到这一点,而且看起来还不错.

I would not use a batch file at all to accomplish this task. BeyondCompare is here to do exactly that, and does it seemingly well.

另一方面,您现在真的想通过批处理文件来执行此操作,建议您安装一个名为

Now on the other hand you really wanna do it via batch file, I'd suggest you install a tool called diff tools, and you'll be able to do something like:

diff.exe <file1> <file2> <htmlfile>

在命令行上.

希望有帮助

更新 作为您的评论的后续,我写了这篇,对我来说似乎也很有效,并且不使用任何外部工具.这是一个简单的示例,但是您可以使其变得更好.

UPDATE As a follow up to your comment, I write this, which also seems to work for me, and doesn't use any external tool. This is a simple example, but you can make it better.

如果存在compare.log del compare.log 如果存在missing.log del missing.log

if exist compare.log del compare.log if exist missing.log del missing.log

for /f "delims=" %%a in ('dir/b/a-d c:\test\1') do (
    if exist "C:\test\2\%%a" (
        fc "c:\test\%%a" "C:\test1\%%a" >> compare.log
    ) else (
        echo %%a is missing >> missing.log
    )
)

暂停

这篇关于使用批处理命令比较文件夹和子文件夹文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆