Skip to content

Commit

Permalink
remove folders correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock committed Mar 22, 2024
1 parent 0dddcae commit 017a7a9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from zipfile import ZipFile
import os
from pathlib import Path
import shutil


# Extract the collection file or deck file to get the .anki21 database.
Expand All @@ -16,11 +16,14 @@ def extract(file, prefix):

def cleanup(proj_dir: Path, files):
"""
Delete all files in prefix that dont have filenames in files
Delete all files/folders in prefix that dont have filenames in files
:param proj_dir:
:param files:
:return:
"""
for file in proj_dir.glob("*"):
if file.name not in files:
os.remove(file)
if file.is_file():
file.unlink()
else:
shutil.rmtree(file)

0 comments on commit 017a7a9

Please sign in to comment.