ElfClean

ElfClean / Guides

How to find large files and duplicates on a Mac

A handful of forgotten videos, disk images and archives often take more space than everything else in your home folder put together. macOS can find them for you, in Finder, in Storage settings or in Terminal. Duplicates take more care: two files with the same name aren't necessarily the same, and two different names can be the same file.

Find large files in Finder

  1. Open a Finder window, select your home folder, and press Command-F.
  2. Click the search location next to "Search:" and choose your home folder rather than This Mac.
  3. Click the first criterion (usually Kind), choose Other, tick File Size and click OK.
  4. Set it to "is greater than" 1 GB (or 500 MB for a fuller list).
  5. Switch to list view (Command-2) and click the Size column to sort.

Choose File, then Save to keep the search in Finder's sidebar for next time. Finder's search uses Spotlight, so it skips folders Spotlight doesn't index, and it doesn't look inside packages such as app bundles or Photos libraries.

To see which folders are large rather than which files, turn on View, then Show View Options, then Calculate All Sizes in list view. It's slow on big folders, but it works.

Use Storage settings

Open System Settings, then General, then Storage, and click the information button next to Documents. The Large Files view lists your biggest files with their size and when you last opened them, and you can delete from there. Downloads shows the same for your Downloads folder, and File Browser lets you open folders by size.

Be careful: deleting from these views removes the file straight away, without going through the Trash. If you're not certain, use Show in Finder and move it to the Trash yourself.

Find large files in Terminal

Every file over 1 GB in your home folder, smallest first, with the space each takes on disk:

find ~ -type f -size +1G -not -flags +dataless -print0 2>/dev/null | xargs -0 du -h | sort -h

-not -flags +dataless leaves out iCloud files that aren't downloaded (more on those below). 2>/dev/null hides "Operation not permitted" for folders macOS keeps private. The first run may ask whether Terminal can open your Desktop, Documents and Downloads.

Two numbers can disagree here. find -size uses a file's stated length, while du shows the space it really takes. Sparse files, such as virtual machine disks, can be many gigabytes long and take very little, so a file can show up in the list with a small size beside it.

To find the biggest folders instead, one level at a time:

du -h -d 1 ~ 2>/dev/null | sort -h | tail -15

Then repeat it on whichever folder is at the bottom, for example du -h -d 1 ~/Movies.

Spotlight can answer the same question almost instantly, because it already knows every indexed file's size:

mdfind -onlyin ~ 'kMDItemFSSize > 1000000000'

The size is in bytes, so 1000000000 is 1 GB. Spotlight leaves out folders it doesn't index, and it includes some packages (such as Xcode archives and apps) as single items.

Before you delete a large file

Find duplicate files

Matching names or sizes isn't enough to call two files duplicates. The reliable test is to compare their contents, and the practical way to do that is a checksum: shasum reads every byte of a file and produces a short fingerprint. Two files with the same SHA-256 fingerprint have the same contents.

This lists files of 1 MB or more in your Downloads folder that have an identical twin, grouped, with a blank line between groups:

find ~/Downloads -type f -size +1M -not -flags +dataless -print0 2>/dev/null \
  | xargs -0 shasum -a 256 \
  | sort \
  | awk '{ h = $1 } n[h]++ == 0 { first[h] = $0; next } n[h] == 2 { print ""; print first[h] } { print }'

Each line is the fingerprint followed by the file's path. Point it at one folder at a time rather than your whole home folder: it reads every file in full, so a large folder takes a long time. Skipping files under 1 MB keeps it quick and leaves out the small files that free little space.

Before removing a copy, check what it's for. A duplicate inside a project, an app's data folder or a library may be the copy something depends on, and deleting it breaks that thing even though the other copy survives. The safe ones to clear are usually in Downloads, on the Desktop and in folders of exports.

Copies that don't take any extra space

On APFS, when you duplicate a file in Finder (Command-D) or copy it within the same disk, macOS may make a clone: both files share the same storage until one is changed. A checksum shows them as duplicates, but deleting one frees almost nothing. There's no simple Terminal command to tell a clone from a real copy; if removing a "duplicate" didn't change your free space, that's the likely reason.

Watch out for iCloud and Photos

If you use iCloud Drive with Optimise Mac Storage, or sync your Desktop and Documents folders, some files on your Mac are only placeholders: the name and size are there, but the contents are in iCloud. Finder shows a cloud icon beside them, and ls -l% marks them with a %.

Photos keeps its originals inside Photos Library.photoslibrary in your Pictures folder. Never delete files from inside it: Photos' database still expects them, and the library can be damaged. To find duplicate photos, use the Duplicates album under Utilities in the Photos sidebar, which merges them properly. Music libraries work the same way.

Deleting from Terminal with rm skips the Trash. When you're clearing out files you found with these commands, move them to the Trash in Finder, and empty it once you're sure.

How ElfClean does it

ElfClean's Files screen has two lists. Largest lists the biggest files in your home folder, from the size you choose in Settings (250 MB to 5 GB), with filters for videos, images, documents and archives. Duplicates compares files of 1 MB or more by their contents, on your Mac, and groups the copies. Nothing is read until you click Find. Quick Look shows any file before you decide.

Both lists leave out Library, the Trash, Photos and Music libraries, apps, Git data, files kept in iCloud and anything you add to Never Touch. Copies that already share their space on disk aren't listed, because removing them frees nothing. Each large file is ticked on its own, one copy of every duplicate always stays, and the copy being removed is checked again just before it goes. Everything goes to the Trash, and History can put it back.

ElfClean's storage map of the home folder, with folders sized by the space they use.

More guides