You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
356 B
Python
12 lines
356 B
Python
|
11 months ago
|
import os
|
||
|
|
|
||
|
|
def remove_empty_folders(folder):
|
||
|
|
for root, dirs, files in os.walk(folder):
|
||
|
|
for dir in dirs:
|
||
|
|
dirpath = os.path.join(root, dir)
|
||
|
|
if not os.listdir(dirpath):
|
||
|
|
print(f"Removing empty folder {dirpath}")
|
||
|
|
os.rmdir(dirpath)
|
||
|
|
|
||
|
|
folder = 'media'
|
||
|
|
remove_empty_folders(folder)
|