How to Compare Two Drives Using robocopy on Windows 11
🔍 WiseChecker

How to Compare Two Drives Using robocopy on Windows 11

Quick fix: Use robocopy in list mode (doesn’t copy, just lists differences): robocopy "C:\Source" "D:\Target" /e /l /njh /njs. Output: files that would be copied. /l = list only, /e = include subdirs, /njh /njs = no job header / summary. To compare bidirectionally: also robocopy "D:\Target" "C:\Source" /e /l /njh /njs.

robocopy’s /l flag: list files that would be processed without actually copying. Useful for comparing two directories. Shows extra files, missing files, files with different timestamps.

Symptom: Want to compare two drives using robocopy on Windows 11.
Affects: Windows 11.
Fix time: ~30 minutes (depending on drive size).

ADVERTISEMENT

What causes this need

Compare two drives to:

  • Verify backup completeness.
  • Find missing files.
  • Sync directories.
  • Audit data integrity.
  • Pre-flight before merging.

Method 1: List mode for comparison

The standard route.

  1. Open Command Prompt.
  2. Run:
    robocopy "C:\Source" "D:\Target" /e /l /njh /njs
    • /e: include all subdirectories.
    • /l: list only; don’t copy.
    • /njh: no job header.
    • /njs: no job summary.
  3. Output: files in Source that don’t match Target (would be copied).
  4. Reverse direction for missing in Source:
    robocopy "D:\Target" "C:\Source" /e /l /njh /njs
  5. For showing extra files in target: /xx flag.
  6. For verbose detail: /v shows skipped files too.

This is the standard fix.

ADVERTISEMENT

Method 2: Detailed report with /log

For documentation.

  1. Save comparison to file:
    robocopy "C:\Source" "D:\Target" /e /l /v /log:C:\compare.log
  2. Open compare.log in Notepad / Excel.
  3. Categories:
    • Same: file in both, matching attributes.
    • Newer: file in target is newer.
    • Older: file in target is older.
    • Lonely: file in source but not target.
    • Extra: file in target but not source.
  4. For Excel analysis: parse log columns.
  5. For PowerShell parsing:
    Get-Content C:\compare.log | Where-Object { $_ -match "Lonely|Extra" }
  6. For comparing file count: (Get-Content C:\compare.log).Count.
  7. For automated comparison: scheduled script that emails differences.

This is the detailed route.

Method 3: Sync after comparison

For acting on differences.

  1. After comparison, sync source to target:
    robocopy "C:\Source" "D:\Target" /e /copy:DAT /xo
    • /xo: exclude older (don’t overwrite newer at target).
  2. For mirror (delete extra from target):
    robocopy "C:\Source" "D:\Target" /mir

    Caution: deletes!

  3. For bidirectional sync: not native robocopy. Use Microsoft SyncToy (legacy) or FreeFileSync (free).
  4. For chronic backup verify: scheduled robocopy /l + email report.
  5. For specific file types: robocopy ... *.docx /e /l.
  6. For exclude patterns: /xf [pattern] exclude files, /xd [pattern] exclude directories.

This is the sync route.

How to verify the fix worked

  • robocopy output lists files differing between source and target.
  • Log file readable.
  • Comparison shows expected differences.
  • If sync follows: drives match.

If none of these work

If output unclear: Verbose flags: /v shows more detail. For binary content comparison: robocopy compares size + timestamp + attributes by default. For byte-level comparison: fc /b file1 file2 (Windows fc tool). For large file count: log files can be huge. Use specific filters. For network drives: slow. Wait or compare locally first. For permissions comparison: /copy:DATSO includes security. For unicode filenames: robocopy handles. For dedupe-based backups: special tools required. Borg, Restic for chunk-level comparison.

Bottom line: robocopy "C:\Source" "D:\Target" /e /l /njh /njs for comparison only. Reverse direction for files missing in source. /log: for saving report. Add /mir to sync after.

ADVERTISEMENT