Skip to content

Instantly share code, notes, and snippets.

@transacplus
transacplus / del_empty_dirs.py
Last active November 1, 2020 10:28 — forked from kylexlau/del_empty_dirs.py
Python delete empty directories, recursive algorithm
import os
def del_empty_dirs(s_dir):
b_empty = True
for s_target in os.listdir(s_dir):
s_path = os.path.join(s_dir, s_target)
if os.path.isdir(s_path):
if not del_empty_dirs(s_path):
b_empty = False