Skip to content

Instantly share code, notes, and snippets.

@adamwgriffin
Created April 4, 2014 06:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamwgriffin/9969228 to your computer and use it in GitHub Desktop.
Save adamwgriffin/9969228 to your computer and use it in GitHub Desktop.
A one-liner to recursively delete empty directories with Ruby
Dir['**/'].reverse_each { |d| Dir.rmdir d if Dir.entries(d).size == 2 }
@adamwgriffin
Copy link
Author

This likely only works on a *nix flavored OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment