mkaramb commited on
Commit
07e2341
·
verified ·
1 Parent(s): 3851673

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -39,6 +39,15 @@ def batch_process_documents(file_path: str, file_mime_type: str) -> tuple:
39
 
40
  def unzip_and_find_jpgs(file_path):
41
  extract_path = "extracted_files"
 
 
 
 
 
 
 
 
 
42
  os.makedirs(extract_path, exist_ok=True)
43
  jpg_files = []
44
  with zipfile.ZipFile(file_path, 'r') as zip_ref:
 
39
 
40
  def unzip_and_find_jpgs(file_path):
41
  extract_path = "extracted_files"
42
+ if os.path.exists(extract_path):
43
+ # Remove the directory and its contents to start fresh
44
+ for root, dirs, files in os.walk(extract_path, topdown=False):
45
+ for name in files:
46
+ os.remove(os.path.join(root, name))
47
+ for name in dirs:
48
+ os.rmdir(os.path.join(root, name))
49
+ os.rmdir(extract_path)
50
+
51
  os.makedirs(extract_path, exist_ok=True)
52
  jpg_files = []
53
  with zipfile.ZipFile(file_path, 'r') as zip_ref: