Tip of the Day: Recursively Delete Empty Folders

Stuck with many nested folders, some of which may be empty? Use the following command to quickly find and delete the empty ones:

find . -empty -type d -delete
  • -empty: File is empty and is either a regular file or a directory
  • -type d: directory
  • -delete: Delete files; true if removal succeeded.
Nicholas Nadeau, Ph.D., P.Eng.
Nicholas Nadeau, Ph.D., P.Eng.

Nicholas Nadeau is the CTO at Halodi Robotics, leading their mission of bringing safe and capable humanoid robots to everyone.