Delete empty directories with find

find -type d -empty lists directories containing no files or subdirectories; pair it with -delete (or -print first) to clean them up safely.

LinuxcleanupdirectoryfindMedium risk
Run `find ~/Downloads -type d -empty -print` to preview, then add `-delete` to remove them.

01Command

Command
$ find ~/Downloads -type d -empty -print

02What it does

After moving files out of a synced or unpacked tree, dozens of hollow directories often remain. `find -type d -empty -delete` removes only truly empty ones — it cannot delete a directory that still contains anything. Note that deleting inner empty dirs can make their parents empty too, so run the command twice, deepest first (find does this naturally by processing depth-first).

03Risk

RiskMedium risk
Requirementsfindutils (preinstalled)
!Warning: Place -delete carefully: if other find expressions run after it, they never execute. Preview with -print before deleting on shared or scripted locations.

04Undo

Undo
$ null

05Sources

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions