Find Empty Files and Directories from Command Line

By  on  

If you are anything like me, you like to keep your projects as tight as possible.  By "tight" I mean no lingering, useless files or directories, because bloat is an incredible annoyance and distraction.  And we don't want distractions, do we?

There's a really easy way to find empty files and directories from the command line:

find /path/to/source/directory -empty

The result will be a list of empty files or directories which you can gloriously remove from your project and relax knowing you're running an incredibly tight ship.

Recent Features

  • By
    9 Mind-Blowing Canvas Demos

    The <canvas> element has been a revelation for the visual experts among our ranks.  Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead.  Here are nine unbelievable canvas demos that...

  • By
    5 Awesome New Mozilla Technologies You&#8217;ve Never Heard Of

    My trip to Mozilla Summit 2013 was incredible.  I've spent so much time focusing on my project that I had lost sight of all of the great work Mozillians were putting out.  MozSummit provided the perfect reminder of how brilliant my colleagues are and how much...

Incredible Demos

  • By
    JavaScript Canvas Image Conversion

    At last week's Mozilla WebDev Offsite, we all spent half of the last day hacking on our future Mozilla Marketplace app. One mobile app that recently got a lot of attention was Instagram, which sold to Facebook for the bat shit crazy price of one...

  • By
    Assign Anchor IDs Using MooTools 1.2

    One of my favorite uses of the MooTools JavaScript library is the SmoothScroll plugin. I use it on my website, my employer's website, and on many customer websites. The best part about the plugin is that it's so easy to implement. I recently ran...

Discussion

  1. Is this the Mac version of the command? The windows version seems to be in a different order. Plus, I can’t seem to find a setting for the empty folders on Windows. If know, could you share? Thanks.

  2. Arpen

    This command results in f:\>find /path/to/source/directory -empty
    FIND: Invalid switch’ using the command line. Does anyone have a better way to find empty folders using CMD line or Powershell?

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