INNER CODE UNIT · Python
wipe_folder
DrewThomasson/VoxNovel · 2GPU_Audio_generation.py:249
def wipe_folder(folder_path):
# Check if the folder exists
if not os.path.exists(folder_path):
print(f"The folder {folder_path} does not exist.")
return
# Iterate through all files in the folder
for filename in os.listdir(folder_path):
file_path = os.path.join(folder_path, filename)
# Check if it's a file and not a directory
if os.path.isfile(file_path):
try:
os.remove(file_path)
print(f"Removed file: {file_path}")
except Exception as e:
print(f"Failed to remove {file_path}. Reason: {e}")
else:
print(f"Skipping directory: {file_path}")