How do I find duplicate files by hash on Windows?

Use PowerShell to group files by SHA256 and confirm identical copies before you delete anything.

Windowshashdisk-cleanupFilesduplicatesdeveloperpowershellLow risk
Run the PowerShell hash-grouping command in the folder you suspect, then compare any flagged pair byte-for-byte before deleting the extra copy.

What this covers

Duplicate photos, downloads and documents can silently eat disk space on Windows. Hashing each file and grouping equal hashes is the reliable way to find true duplicates, not just files with the same name. This guide uses built-in PowerShell and cmd tools, so there is nothing extra to install.

Symptom

?Your drive is filling up faster than expected, or you keep finding files like `IMG_2043 (1).jpg` and `report copy.docx`. Folder sizes look inflated, but you cannot tell which copies are actually identical without opening and comparing them one by one.

See where the space is going

Start by listing the largest files in your user folder. This tells you which folders are worth scanning for duplicates, so you do not hash an entire drive unnecessarily. Replace the sample path with your own top-level folder. If the largest files are all in one project or photo folder, that is the folder to scan next. Worked if you have a short list of big files and their full paths.

Recursively list files sorted by size, largest first, to hunt down disk-space hogs in any directory tree.

Command
$ Get-ChildItem -Path C:\Users\me -Recurse -File | Sort-Object Length -Descending | Select-Object -First 20 Length, FullName

Group files by SHA256 to find duplicates

This is the core step: PowerShell hashes every file under the folder you choose and groups files that share the same hash. Replace the sample path with the folder from the previous step or the folder you suspect. The output shows each duplicate group with the full path and hash. Worked if you see groups with Count greater than 1; files in the same group are identical by content. Review each group and decide which copy to keep, but do not delete yet.

Group duplicate files by SHA256 hash with Get-FileHash and Group-Object to clean up copied photos and documents on Windows.

Command
$ $files = Get-ChildItem 'C:\Users\me\Pictures' -Recurse -File
$files | Get-FileHash -Algorithm SHA256 |
  Group-Object Hash | Where-Object Count -gt 1 |
  ForEach-Object { $_.Group | Select-Object Path, Hash } | Format-Table -AutoSize

Confirm a pair byte-for-byte before deleting

Pick one duplicate group from the previous step and use the built-in byte-for-byte compare on the two full paths you are checking. Replace the sample file names with the exact paths from the duplicate group. This byte-level check catches any path mix-up and confirms the files are truly identical. Worked if the compare reports no differences. Once you see that, delete the extra copy and keep the one you chose.

The built-in file compare tool reports whether two text or binary files differ and shows every mismatching byte with its hex offset.

Command
$ fc /b file1.bin file2.bin
!Hash grouping only lists candidates. Do not delete a file until you have confirmed it is byte-identical to the copy you are keeping. A hash collision is extremely unlikely with SHA256, but a wrong path or an edited file can still cause data loss. Keep a backup or use the Recycle Bin for the first cleanup.

How to confirm it worked

You should see one or more groups where every file shares the same SHA256 hash. After you remove the extra copies, rerun the grouping and the duplicate count should drop to zero for those folders.

Sources

  • Get-ChildItem | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents Get-ChildItem with -Recurse and -File, and that FileInfo objects expose the Length property, which can be sorted with Sort-Object.
  • Get-ChildItem - PowerShell
    SS64 · technical · 2026-09-17
    Evidence: SS64 shows Get-ChildItem piped into Sort-Object and Select-Object to rank files, e.g. by file size.
  • Get-FileHash
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Get-FileHash computes the SHA256 hash of files piped in, so identical files produce identical hashes that can be grouped.
  • Get-FileHash - SS64
    SS64 · technical · 2026-09-17
    Evidence: Get-FileHash accepts pipeline input of FileInfo objects and supports SHA256 as the default algorithm.
  • fc | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents fc /b as performing a binary comparison, displaying every differing byte with its offset.
  • File Compare - fc - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: SS64 lists fc switches including /b for binary comparison, /c to ignore letter case, and /n to show line numbers in ASCII mode.

Last verified: 2026-09-22

Related guides