Redmind commited on
Commit
009c1cf
·
verified ·
1 Parent(s): 46558f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -1281,15 +1281,14 @@ def create_pdf(cname,ename,account_number, directory):
1281
 
1282
  def zip_files_in_folder(directory, output_zip):
1283
  # Initialize the ZIP file
1284
- directory = "./"
1285
  with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
1286
- # Walk through the directory and add PDF files to the ZIP
1287
- for root, _, files in os.listdir(directory):
1288
- for file in files:
1289
- if file.endswith(".pdf"): # Only include PDF files
1290
- file_path = os.path.join(root, file)
1291
- # Add file to the ZIP archive
1292
- zipf.write(file_path, file)
1293
  print(f"ZIP file created: {output_zip}")
1294
 
1295
  def directory_exists(repo_id, directory, token):
 
1281
 
1282
  def zip_files_in_folder(directory, output_zip):
1283
  # Initialize the ZIP file
 
1284
  with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
1285
+ # List all files in the directory
1286
+ for file in os.listdir(directory):
1287
+ file_path = os.path.join(directory, file)
1288
+ # Check if it's a PDF file and a regular file (not a directory)
1289
+ if file.endswith(".pdf") and os.path.isfile(file_path):
1290
+ # Add file to the ZIP archive
1291
+ zipf.write(file_path, file) # Save with its filename in the ZIP
1292
  print(f"ZIP file created: {output_zip}")
1293
 
1294
  def directory_exists(repo_id, directory, token):