批处理文件以比较2个文件夹 [英] Batch file to compare 2 folders

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

问题描述

我如何能够创建一个批处理文件来比较2个具有相同文件集但修改日期不同的文件夹?我已经在互联网上检查了一些代码,但它只会检查文件是否存在于其他文件夹中.

How would I be able to create a batch file to compare 2 folders with the same set of files but different modified date? I have check for some codes in the internet but it would only check if the file exist in the other folder.

任何帮助将不胜感激.谢谢.

Any help would be appreciated. Thanks.

推荐答案

@echo off
Set folder1=c:\first folder
Set folder2=c:\second folder
Cd /D "%folder1%"
For %%a in (*.*) do (
   For %%b in ("%folder2%\%%a") do (
      If "%%~Ta" neq "%%~Tb" echo Different date/time in file %%a
   )
)

您可以只比较将%%~T...的结果分割成变量的日期,然后比较变量.

You may compare just the date splitting the result of %%~T... in variables, and then comparing the variables.

您还可以检查第二个文件夹中是否不存在该文件,或者比较文件的大小等...

You may also check if the file does not exist in second folder, or compare their sizes, etc...

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

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