Spaces:
Running
Running
File size: 386 Bytes
aff0a09 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import os
import shutil
def remove_content_from_dir(folder):
for filename in os.listdir(folder):
file_path = os.path.join(folder, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception as e:
print('Failed to delete %s. Reason: %s' % (file_path, e)) |