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:

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:

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.

2. Notepad++ with Compare Plugin

If you use Notepad++, the Compare plugin is excellent.

  1. Install Plugin: Plugins > Plugins Admin > Search "Compare" > Install.
  2. Open two files in Notepad++.
  3. Go to Plugins > Compare > Compare.
  4. Files will be side-by-side with diffs highlighted.

3. Visual Studio Code

Great for developers.

  1. Open VS Code.
  2. In Explorer sidebar, right-click first file > Select for Compare.
  3. Right-click second file > Compare with Selected.
  4. 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
User