Spaces:
Running
Running
File size: 495 Bytes
aff0a09 5ac7dcf aff0a09 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import os
import shutil
import time
def get_file_name(prefix: str) -> str:
return f"{prefix}_{time.strftime('%Y%m%d-%H%M%S')}.mp4"
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)) |