fixmint
EN

How to find duplicate files and free disk space safely

By · · 4 min read

A duplicate is a file whose contents match another file's, byte for byte. The same name is not enough, and the same size is not enough either. To find real duplicates, group files by size, then compare a fingerprint of each file's contents. Before you delete any copy, check that one good copy will remain and that your backup holds the rest.

Find duplicate filesSame files saved twiceDo it free

Why the same size can still mean different files

Size is the number of bytes in a file. Two files can match by chance, or because they share a fixed layout: a form template, a game save with a set length, or a document where one digit changed from 12 to 13. The size stays the same and the content does not.

Names are no better. "photo (1).jpg" can be a different picture from "photo.jpg", and two files called "budget.xlsx" in different folders can hold different numbers. Use size to narrow the list, and content to decide.

How hashing proves two files match

A hash function reads every byte of a file and produces a short fingerprint of fixed length. SHA-256 is a common one. It always gives 64 hexadecimal characters (the digits 0 to 9 and the letters a to f), whatever the file size. Change one byte and the fingerprint changes completely.

So two files with the same SHA-256 fingerprint are, for practical purposes, identical. No known method can make two different files produce the same SHA-256 on purpose.

Reading a whole file is the slow part, so a good finder works in stages:

  1. Group files by size. A file whose size no other file shares cannot be a duplicate, so it is skipped.
  2. Fingerprint only the files left in each group.
  3. Files with the same fingerprint are duplicates.

Look-alike photos are a different job

A photo sent through a messaging app is usually recompressed and saved again. Its bytes change, so its fingerprint changes too. Two photos of the same scene, one resized or cropped, look the same to you but hold different bytes. An exact-match finder reports them as different.

For these, compare by eye. Open the photos side by side in your viewer, and keep the larger, sharper one. Delete the smaller copies only after you have looked.

Compare a folder with its backup

Before you delete anything from a working folder, check that the backup has it. Compare the two folders to see what is only on one side, what changed and what moved.

Two modes matter:

  • Quick mode matches files by their path. It calls two files the same when their sizes match, and, between two folders, when their modified times match too. It is fast, but a changed file whose size and time both stay the same can slip through.
  • Check contents reads each file whose size matches on both sides and compares SHA-256 fingerprints. It finds a change that kept the size, and it finds files that were moved or renamed.

Use Check contents before you rely on a backup. The line that matters most is "only in A": those files have no copy on the other side.

What fills a disk

Disks fill up in a few predictable places: old videos, phone backups, a downloads folder full of installers, disk images, and whole copies of folders made just in case. See what takes the space first. It shows the largest folders, so you start where the space is instead of deleting files at random.

Duplicates waste space in proportion to their size. A 4 GB video (4 gigabytes) saved three times uses 12 GB. Keep one copy and you free 8 GB.

Delete the extra copies safely

  1. Look at each group of identical files. Decide which copy to keep: the one in the folder you actually use, or the one with the clearest name.
  2. Open the copy you will keep. Confirm that it opens and looks right.
  3. Check the backup. Compare the folders to confirm the backup holds that file.
  4. Move the extra copies to the Recycle Bin or Trash, not a permanent delete. Empty it only after a few days of normal use with nothing missing.
  5. Empty the bin. Moving files to the bin does not free disk space until it is emptied.

Edge cases

  • Hard links and shortcuts. Some files that look like duplicates are two names for the same data on disk. Deleting one name frees no space, because the data stays for the other name.
  • Synced folders. A cloud or sync folder passes each delete on to every device it syncs with. Check the sync settings before you delete there.
  • Program folders. Applications and the system keep identical files that a program may need in several places. Clean your personal folders, not program folders.
  • Photo libraries. Photo apps keep their own library. Delete duplicates inside the app, not in the folder behind it, or the library can lose track of its photos.

Comments

    No comments yet. Be the first.

    Your rating (optional)

    Your email is never shown or kept.

    Cover of Digital Workflow ToolkitDigital Workflow Toolkit

    Recipes, templates and patterns for chaining small file jobs (convert, rename, compress, merge) into workflows that run the same way every time.

    $19.00Get it on Gumroad