Locate Empty Directories from Command Line

By  on  

As a software engineer that lives too much of his life on a computer, I like keeping my machine as clean as possible. I don't keep rogue downloaded files and removes apps when I don't need them. Part of keeping a clean, performant system is removing empty directories.

To identify empty directories, I use the following command:

find . -type d --empty

To remove empty directories, we can add a --delete flag:

find . -type d --empty --delete

Keeping a clean machine is easy when you know the tools that can help you. find makes identifying and eliminating easy, so don't be afraid to use it!

Recent Features

  • By
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

  • By
    Create Namespaced Classes with MooTools

    MooTools has always gotten a bit of grief for not inherently using and standardizing namespaced-based JavaScript classes like the Dojo Toolkit does.  Many developers create their classes as globals which is generally frowned up.  I mostly disagree with that stance, but each to their own.  In any event...

Incredible Demos

  • By
    Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo JavaScript

    I'm what you would consider a bit of a GitHub fanboy. We all know that GitHub is the perfect place to store repositories of open source code, but I think my love of GitHub goes beyond that. GitHub seems to understand that most...

  • By
    CSS Sprites

    The idea of CSS sprites is pretty genius. For those of you who don't know the idea of a sprite, a sprite is basically multiple graphics compiled into one image. The advantages of using sprites are: Fewer images for the browser to download, which means...

Discussion

  1. Jim L

    A minor change as it should have a single ‘-‘ on the empty predicate:

    find . -type d -empty

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!