我需要windows批处理脚本来递归比较两个文件夹(文件夹A和文件夹B),并只显示在文件夹A中丢失的文件。
我试过了,但它不是递归的:
@echo off
if "%2" == "" GOTO Usage
cd /D %1
if errorlevel 1 goto usage
for %%x in (*.*) do if NOT exist %2\%%x echo missing %2\%%x
cd /D %2
for %%x in (*.*) do if NOT exist %1\%%x echo missing %1\%%x
goto end
:usage
echo Usage %0 dir1 dir2
echo where dir1 and dir2 are full paths
:end
发布于 2014-02-13 05:36:59
快速检查的方法是尝试以下方法
Cd Folder1
dir *.* /s > Folder1.txt
cd Folder2
dir *.* /s > Folder2.txt
比较两个文本文件以查看文件中的差异
发布于 2014-02-14 06:13:10
您应该使用diff.exe:https://code.google.com/p/unix-cmd-win32/downloads/detail?name=diff.exe&can=2&q=
然后,比较这些树:
@echo off
if "%1" == "" GOTO Usage
if "%2" == "" GOTO Usage
cd /D %1
if errorlevel 1 goto usage
cd /D %2
if errorlevel 1 goto usage
set TEMP1=C:\temp\dir1
set TEMP2=C:\temp\dir2
dir /s %1 > %TEMP1%
dir /s %2 > %TEMP2%
diff.exe %TEMP1% %TEMP2%
del %TEMP1% %TEMP2%
goto end
:usage
echo Usage %0 dir1 dir2
echo where dir1 and dir2 are full paths
:end
https://stackoverflow.com/questions/21739911
复制相似问题