awacke1 commited on
Commit
d965517
1 Parent(s): 8f40986

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -229,13 +229,19 @@ def main():
229
 
230
 
231
  if st.sidebar.button("🗑 Delete All"):
232
- # Compose all_files
233
- all_files = glob.glob("*.*")
234
- all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
235
- all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
236
-
237
- for file in all_files:
238
- os.remove(file)
 
 
 
 
 
 
239
  st.experimental_rerun()
240
 
241
  if st.sidebar.button("⬇️ Download All"):
 
229
 
230
 
231
  if st.sidebar.button("🗑 Delete All"):
232
+ # Clear history file
233
+ with open("history.json", "w") as f:
234
+ json.dump({}, f)
235
+
236
+ # Delete all files in subdirectories
237
+ for subdir in glob.glob('*'):
238
+ if os.path.isdir(subdir) and subdir not in EXCLUDED_FILES:
239
+ for file in os.listdir(subdir):
240
+ file_path = os.path.join(subdir, file)
241
+ os.remove(file_path)
242
+ st.write(f"Deleted: {file_path}")
243
+ os.rmdir(subdir) # Remove the empty directory
244
+
245
  st.experimental_rerun()
246
 
247
  if st.sidebar.button("⬇️ Download All"):