Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

How do I compare two folders to see which files are different?

Quick answer

First compare the folders’ file lists, including subfolders, to find files present on only one side. For files with matching paths, record size and modified time as metadata, then use a content comparison or hashes to check contents when needed. Windows’ comp command compares file contents, while PowerShell’s Get-FileHash can compare selected files. Review the results before changing either folder.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

What should I compare first? I want to know what is missing as well as what changed.

Geez

Start by treating the folders as two separate inventories, which we’ll call Folder A and Folder B. Include subfolders on both sides, and compare relative paths—not just file names—because two files with the same name can be in different subfolders.

Make three lists: paths found only in A, paths found only in B, and paths present in both. The first two lists identify entries found on only one side; they do not determine which folder has the version you want. If you use a comparison utility, check that its settings include subdirectories. Microsoft describes WinDiff as a graphical option for comparing folders of ASCII text files, with an option to include subdirectories. That description does not establish that it is available by default or that it compares arbitrary file types. [S1]

Follow-up question

For files found in both folders, can I use size and modified date to decide whether they differ?

Geez

Record size and modified time as metadata, not as a content check. A difference in either is a reason to review the file, but matching metadata does not establish that the contents match. Likewise, a different modified time alone does not tell you what changed in the file.

Keep the comparison columns separate: relative path, size, modified time, and content result. Mark size and time as metadata. Mark a content result only when you have compared the contents. That way, the report distinguishes what you observed from what you verified.

Follow-up question

How can I check whether matching files really have the same contents on Windows?

Geez

For a selected pair of files, Windows’ comp command compares contents byte by byte and reports file locations and names. It can check matched files, but it does not create a complete folder inventory or explain metadata-only differences. Microsoft lists it for Windows 10 and Windows 11. Review the targets and output before taking action. [S2]

Another option is PowerShell’s Get-FileHash: calculate a hash for each selected file and compare the results. Microsoft says identical hashes indicate identical contents; the default algorithm is SHA256. A hash does not compare folder trees, names, or timestamps. The cited documentation is for PowerShell 7.5, so check the help for the version you are using rather than assuming every version behaves identically. [S3]

With either method, select corresponding files deliberately. A content match does not tell you whether either file is stored at the intended path.

Follow-up question

Can you give me a practical report format and a safe order for doing this?

Geez

Yes. Work from copies or read-only views if practical, and do not merge, overwrite, or delete files just because a comparison labels them different. Treat a difference as something to review, not as an instruction about which version to keep.

Use this copyable report format:

Path | Folder A | Folder B | Size/time notes | Content check | Decision [relative path] | present/missing | present/missing | [observations] | not checked/same/different | [review later/keep A/keep B/resolve]

Example with hypothetical values: [reports/summary.txt] | present | present | same size; different modified time | different contents | review which version is intended. This records an example result; it does not determine which file is authoritative.

For many files, compare inventories first, then verify the contents of selected matched files. Record the method used, such as byte comparison or hashes, so a reviewer can distinguish a content check from metadata notes.

A practical checklist

  • Choose Folder A and Folder B and record their locations without changing either folder.

  • Compare relative paths, including subfolders, and list entries found only on each side.

  • For paths present in both, record size and modified time as metadata, not as a content check.

  • Use a content comparison or hashes for files whose contents need verification.

  • Record the method and result separately from any decision about which version to keep.

  • Review differences before merging, overwriting, or deleting files.

A few more useful answers

Does a matching file name mean the files are identical?

No. Names identify entries, not their contents. Compare the corresponding files’ contents if you need to check whether they match.

Does a matching hash compare the folder structure too?

No. A hash checks file contents, not paths, names, timestamps, or whether a file is missing from one folder. Compare the inventories separately.

Can WinDiff compare every kind of file?

The cited Microsoft description scopes WinDiff to folders containing ASCII text files and does not establish arbitrary binary-file comparison. Use a method suited to the contents you need to check.

Sources

References used for this guide.

  1. [S1] How to use the Windiff.exe utility to compare folders
    learn.microsoft.com · Checked
  2. [S2] comp command: compare files or sets of files
    learn.microsoft.com · Checked
  3. [S3] Get-FileHash: calculate and compare file content hashes
    learn.microsoft.com · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work