Comparing Files in Windows
Complete guide on how to compare files and folders in Windows to find differences, duplicates, or changes.
Built-in Command Line Tools
Windows includes native tools to compare files via Command Prompt (CMD).
1. FC (File Compare)
Basic tool to compare two files.
fc file1.txt file2.txt
Options:
/N: Show line numbers/C: Ignore case/W: Compress white space
Example:
fc /N C:\doc1.txt C:\doc2.txt
2. COMP (Compare)
Binary comparison of files.
comp file1.bin file2.bin
It tells you if files are different sizes or content, but gives less readable text output than fc.
3. PowerShell Compare-Object
PowerShell offers a powerful object-oriented comparison.
Compare-Object (Get-Content file1.txt) (Get-Content file2.txt)
Output:
=>: Content only in the second file (DifferenceObject)<=: Content only in the first file (ReferenceObject)
Command to see differences:
$f1 = Get-Content -Path "C:\file1.txt"
$f2 = Get-Content -Path "C:\file2.txt"
Compare-Object -ReferenceObject $f1 -DifferenceObject $f2
GUI Tools (Recommended)
For visual comparison, third-party tools are much easier to use.
1. WinMerge (Free & Open Source)
The standard for file comparison on Windows.
- Download: winmerge.org
- Features: 3-way compare, image compare, folder compare.
- Usage:
- Open WinMerge
- Drag and drop two files
- Differences are highlighted in Yellow
2. Notepad++ with Compare Plugin
If you use Notepad++, the Compare plugin is excellent.
- Install Plugin: Plugins > Plugins Admin > Search "Compare" > Install.
- Open two files in Notepad++.
- Go to Plugins > Compare > Compare.
- Files will be side-by-side with diffs highlighted.
3. Visual Studio Code
Great for developers.
- Open VS Code.
- In Explorer sidebar, right-click first file > Select for Compare.
- Right-click second file > Compare with Selected.
- Shows a beautiful diff view.
Comparing Folders
Validating Backups with Robocopy
Check if a backup matches source without copying:
robocopy "C:\Source" "D:\Backup" /E /L /NS /NJS /NJH /NDL /FP /LOG:diff.txt
/L: List only (don't copy)/E: Recursive- Logs differences to
diff.txt