Step 7 of 82
← Home
πŸ“ Phase: Foundation & Rules

Step 7 Comparing Files in Windows

Why this step? Compare config files before and after changes to spot mistakes early.

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:
    1. Open WinMerge
    2. Drag and drop two files
    3. Differences are highlighted in Yellow

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
  • /L : List only (don't copy)
  • /E : Recursive
  • Logs differences to diff.txt