Skip to content

Instantly share code, notes, and snippets.

@hughdbrown
Created April 3, 2017 20:41
Show Gist options
  • Save hughdbrown/42159ae759964b1e60bdf8e7fa5caca8 to your computer and use it in GitHub Desktop.
Save hughdbrown/42159ae759964b1e60bdf8e7fa5caca8 to your computer and use it in GitHub Desktop.
List directories that are empty
#!/usr/bin/env python
from __future__ import print_function
import os
import os.path
def find_empty_folders(start_dir='.'):
for root, dirs, files in os.walk(start_dir):
for d in dirs:
fulldir = os.path.join(root, d)
if not(os.listdir(fulldir)):
print(fulldir)
if __name__ == '__main__':
find_empty_folders()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment