From 8f7d4845596c008c486869848bd2d72a68e3e86f Mon Sep 17 00:00:00 2001 From: phixxy Date: Thu, 5 Mar 2026 01:07:55 -0800 Subject: [PATCH] cleanup of list_all and delete_all --- skratch.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/skratch.py b/skratch.py index 64f01a8..695b3da 100755 --- a/skratch.py +++ b/skratch.py @@ -11,10 +11,8 @@ def make_dir(d): os.mkdir(d) def delete_all(d): - if not os.path.exists(d): - print("Skratch path doesn't exist") - else: - list_all(d) + fc = list_all(d) + if fc: x = input("Delete the above files? y/N ") if x.lower() == 'y': for file in os.listdir(d): @@ -26,11 +24,14 @@ def delete_all(d): def list_all(d): if not os.path.exists(d): print("Skratch path doesn't exist") - elif os.listdir(d) == []: + return 0 + files = os.listdir(d) + if files == []: print("No skratch files exist") else: - for file in os.listdir(d): + for file in files: print(file) + return len(files) def get_editor(use_v): v = os.getenv("VISUAL")