An exact duplicate is a file whose contents match another file byte for byte. You can find them in Windows by grouping files by size and then comparing a cryptographic hash of each group, which a short PowerShell command can do. Then you keep one copy of each, remove the others through the Recycle Bin, and leave alone any folder an app depends on. File names and dates alone do not prove anything, so do not use them to decide.

Photo-style illustration: two identical sheets with the same grey lines on a desk, one with a blue tab as the copy to keep, beside an open cardboard bin.

What counts as a duplicate

Three different things get called duplicates, and only one is safe to treat as such.

  • Same name. Two files called report.docx in different folders can hold different text.
  • Same size. Two photos can share a size by coincidence, and a renamed copy keeps its size but loses its name.
  • Same content. Every byte matches. This is the only test that tells you removing one loses nothing.

An exact-content check will not find near-duplicates. A photo saved again at a different quality, or a document with one word changed, has a different hash. That is a limit of the method, and it also keeps the method safe: it never flags two files that differ.

Why a hash works

A hash function turns a file's content into a short fingerprint. Microsoft's documentation for Get-FileHash says that if the hash values of two files are identical, the contents of the files are also identical, and that the cmdlet uses the SHA256 algorithm by default (checked in October 2026). Checking size first saves time, because two files of different sizes cannot match, so only files of the same size need to be hashed.

Choose where to look

Decide your scope before you scan. Good places are folders you organise yourself: a photo library, a music folder, a Downloads folder, an archive on an external drive. Poor places are folders where duplicates are expected and on purpose.

  • C:\Windows, Program Files and ProgramData. Programs keep their own copies of shared files, and removing one can stop a program from starting.
  • Project and package folders, such as dependency folders in software projects, where tools expect every copy to exist.
  • Cloud sync folders, until you know which files are really stored on this PC (see below).
  • Backups. A copy that exists for safety looks exactly like a duplicate.

Find exact duplicates with PowerShell

This method only reads files and deletes nothing. Open Windows PowerShell or Terminal, replace the folder path with your own, and run it. It can take a long time on a folder with many large files, and we have not tested this exact line on every Windows 10 and 11 build.

Get-ChildItem "D:\Photos" -Recurse -File -ErrorAction SilentlyContinue |
            Where-Object { $_.Length -gt 0 } |
            Group-Object Length |
            Where-Object { $_.Count -gt 1 } |
            ForEach-Object { $_.Group } |
            Get-FileHash |
            Group-Object Hash |
            Where-Object { $_.Count -gt 1 } |
            ForEach-Object { $_.Group | Select-Object Hash, Path }

It does five things in order. It lists the files under the folder and skips empty ones, because empty files all look alike. It groups the files by size and keeps only sizes that occur more than once. It computes the SHA256 hash of those files. It groups them by hash. And it prints the hash and path of every file whose hash occurs more than once. Files that share a hash are exact duplicates.

If the output is empty, there are no exact duplicates in that folder. If the output is long, work on it one group at a time. The cmdlets involved are documented as Get-ChildItem and Get-FileHash.

Careful with OneDrive and other cloud folders

A file that is online-only does not take space on your PC, so removing its duplicate frees nothing locally. Microsoft's OneDrive Files On-Demand page says opening an online-only file downloads it. A script that reads every file to hash it can therefore trigger large downloads, so keep cloud folders out of the scan unless you want that. Removing a file inside a synced folder also removes it from the cloud copy once the sync runs.

On NTFS drives a single file can have more than one name. Microsoft's fsutil hardlink documentation explains that on NTFS volumes each file can have multiple hard links, so one file can appear in many directories, and that programs can open any of the links. Two such entries are not two copies. They are one file with two names. Deleting one name frees no space, and the hash method above will list them as a match because they are the same data.

Windows itself uses hard links heavily in the WinSxS folder, which is another reason to keep system folders out of any duplicate scan.

Decide which copy to keep

For each group of matching files, pick one to keep before you remove anything. Some questions help.

  1. Which folder is the organised one? Keep the copy in the library you actually use, and remove the stray one in Downloads or on the desktop.
  2. Does anything point to a copy? Music players, photo apps, shortcuts and documents with linked files can refer to a specific path. Check before removing the one they use.
  3. Is one a backup on purpose? If so, it is not a duplicate for this purpose.
  4. Is it still unclear? Keep both and move on. Space saved from one file rarely justifies the risk.

Whichever you pick, make sure at least one verified copy stays. Open it first and check that it is complete.

Remove copies through the Recycle Bin

Select the copy you chose to remove in File Explorer and press Delete. On a normal local drive Windows moves it to the Recycle Bin, where you can restore it until the bin is emptied. Read the confirmation prompt. If it says the file will be permanently deleted, stop. That is how Windows warns you that the Recycle Bin will not hold the file, which can happen on some removable drives and network locations. We have not found a Microsoft page that lists every case, so treat the prompt as the authority. Move the file somewhere else instead, or decide whether you really want it gone.

The bin has a size limit per drive, which you can see by right-clicking the Recycle Bin and choosing Properties. Keep that in mind if you remove large files. Space is not freed until you empty the bin, and emptying is permanent. Wait a few days before you do it, in case you notice that something is missing.

Duplicates that are not worth chasing

Many small matches are not worth your time. Identical icons, config files and library files inside app folders belong to the apps. Removing them saves almost nothing and risks breaking something. A realistic target is large files: videos, disk images, installers, exported archives and photo folders copied twice.

Duplicate file finder in SafeClean

Choose the folders to scan. SafeClean groups files by size, compares them, checks the full contents with a cryptographic hash and checks again just before acting. Folders marked as reference folders are never touched and are preferred as the copy to keep. At least one copy always stays; the others go only to the Recycle Bin, and nothing happens if the Recycle Bin is unavailable. Files that are open, changing or hard-linked to the same data are skipped.

Get SafeClean on Microsoft Store Features and pricing

Frequently asked questions

Can two different files have the same hash?

For SHA256, Microsoft's documentation treats a matching hash as proof of identical contents, and in practice accidental collisions are not a concern. For files you cannot replace, you can still open both and compare them before you remove one.

Is it safe to delete duplicates found by size and name?

No. Name and size are not proof of identical content. Use a content hash, and keep one verified copy.

Will Windows warn me before it deletes something permanently?

Usually, yes. Read the prompt. A message about permanent deletion means the file will not go to the Recycle Bin.

Why did removing duplicates free no space?

The files may be hard links to the same data, online-only cloud files, or still in the Recycle Bin. Empty the bin, and check Size on disk in Properties for the real figure.

Does this find similar photos?

No. A resized or re-saved photo has different contents and a different hash. This method finds only exact copies.