How to do a Quick Compare of 2 directories?

Two- and three-way folder compare and merge issues.

How to do a Quick Compare of 2 directories?

Postby j2027 » Sat Apr 10, 2010 3:34 am

How to do a Quick Compare of 2 directories?

Quick Compare works fine, when comparing 2 files.
Example:
uc -qc "F:\1\New.txt" "F:\2\New.txt"
Same

But how can the UC program (UltraCompare) do Quick Compare for all files and all folders in a directory?

The desired end result after comparing 1000's of files in dozens of directories would be something like this: (-d = directory)
uc -qc -d "F:\1\" "F:\2\"
Same

Background, using:
Win XP Pro
UltraCompare version 7.00.0.1018
j2027
Newbie
 
Posts: 2
Joined: Sat Apr 10, 2010 3:08 am

Re: How to do a Quick Compare of 2 directories?

Postby Mofi » Sat Apr 10, 2010 5:58 am

There is no quick folder compare option. You can use the following batch file. For a description see the comments (rem).

@echo off
rem Run a full binary recursive folder compare with not equal results written into a text file.
uc.com -fb -dmf -r -d F:\Temp\Test1\ F:\Temp\Test2\ -ne -o F:\Temp\Result.txt

rem Check if a binary file is listed in the results file because of a difference.
%systemroot%\system32\find.exe /c "| Binary    |" F:\Temp\Result.txt >nul
if errorlevel 1 goto !CheckText
rem Different binary file listed in the results file.
echo "DIFFERENT"
goto !Exit

:!CheckText
rem Check if a text file is listed in the results file because of a difference.
%systemroot%\system32\find.exe /c "| Text      |" F:\Temp\Result.txt >nul
if errorlevel 1 goto !CheckEmptyDir
rem Different text file listed in the results file.
echo "DIFFERENT"
goto !Exit

:!CheckEmptyDir
rem Check if an empty subdirectory exists in one folder and not in the other.
%systemroot%\system32\find.exe /c " none " F:\Temp\Result.txt >nul
if errorlevel 1 goto !AllEqual
rem Different empty subdirectories in one or both folders.
echo "DIFFERENT"
goto !Exit

:!AllEqual
echo "SAME"

:!Exit
del F:\Temp\Result.txt >nul
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: How to do a Quick Compare of 2 directories?

Postby j2027 » Sat Apr 10, 2010 11:28 am

Hello Mofi
Thank you for this idea.

But there is 1 thing that did not work for me:

" none " in CheckEmptyDir does not work for me because " none " exist when directories ARE the same.

Here is what is being tested....

@echo off
uc.com -fb -dmf -r -d "f:\1\" "F:\2\" -ne -op "F:\TemP1.txt"

:!CheckText
C:\WINDOWS\system32\find.exe /c "| Text" "F:\TemP1.txt" > "F:\TemP2.txt"
if errorlevel 1 goto !CheckBinary
echo Different - Text
goto !Exit

:!CheckBinary
C:\WINDOWS\system32\find.exe /c "| Binary" "F:\TemP1.txt" > "F:\TemP2.txt"
if errorlevel 1 goto !CheckEmptyDir
echo Different - Binary
goto !Exit

:!CheckEmptyDir
C:\WINDOWS\system32\find.exe /c " none " "F:\TemP1.txt" > "F:\TemP2.txt"
if errorlevel 1 goto !AllEqual
echo Different - Directory
goto !Exit

:!AllEqual
echo Same
Pause

:!Exit
Pause
j2027
Newbie
 
Posts: 2
Joined: Sat Apr 10, 2010 3:08 am

Re: How to do a Quick Compare of 2 directories?

Postby Mofi » Sun Apr 11, 2010 7:27 am

I'm using UC v7.10.0.1012. This version does not write equal directories into the results file with word none. Command line parameter -ne should result in having only different files and folders in the results file. The word none should be present only in the results file when either a subdirectory or a file exists in only one of the 2 directories. For the tests I have done this works.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Folder Compare and Merge