DenisT's picture
made utils a file instead of folder
5ac7dcf
raw
history blame
495 Bytes
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))