From bf454bf09b54feea1446e3ea8493cf9ba344cc52 Mon Sep 17 00:00:00 2001 From: Sarahtonin Date: Mon, 6 Apr 2026 01:08:57 +0200 Subject: [PATCH] Removed Running, since it's very ineffective. --- Config.toml | 2 +- SaraSortd.py | 37 +++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Config.toml b/Config.toml index 3063d2d..6891c07 100644 --- a/Config.toml +++ b/Config.toml @@ -1,5 +1,4 @@ Title = "SaraSortd Config" -Running = 0 SafeMode = 1 SilentMode = 0 CheckInput = 3 @@ -35,6 +34,7 @@ DirConfName = ".@Config" All = "[h]:[n]:[s] | " Start = "Started SaraSortd." NotStart = "Error: Failed to start SaraSortd." +Stop = "\nStopped SaraSortd." MatchPattern = "Checking %%." Sorted = "Sorted %%." NotSorted = "Error: Failed to sort %%. No valid output directory." diff --git a/SaraSortd.py b/SaraSortd.py index 72d1aec..355e458 100644 --- a/SaraSortd.py +++ b/SaraSortd.py @@ -311,7 +311,6 @@ def Init(): LogWrite(TextOutput) Speak(TextOutput) - UpdateConf(ConfPath, "Running", 1) Main() else: @@ -327,24 +326,30 @@ def Main(): for Output in ConfDirs["OutputDir"]: Output = Parse(String = Output) Dir(Output) + + try: + while True: + for Input in ConfDirs["InputDir"]: + InputPath = Parse(Input) + + if not os.path.exists(InputPath): + continue - while (GetConf("Running", ConfPath) == 1): - for Input in ConfDirs["InputDir"]: - InputPath = Parse(Input) - - if not os.path.exists(InputPath): - continue + for FileName in os.listdir(InputPath): + FilePath = os.path.join(InputPath, FileName) - for FileName in os.listdir(InputPath): - FilePath = os.path.join(InputPath, FileName) + if os.path.isfile(FilePath): + FileName = os.path.basename(FilePath) + if (FileName.startswith(".") and Conf["DotFiles"] == 0): + continue + Sort(FilePath) + + time.sleep(Conf.get("CheckInput", 10)) - if os.path.isfile(FilePath): - FileName = os.path.basename(FilePath) - if (FileName.startswith(".") and Conf["DotFiles"] == 0): - continue - Sort(FilePath) - - time.sleep(Conf.get("CheckInput", 10)) + except KeyboardInterrupt: + TextOutput = GetConf("Stop", ConfPath) + LogWrite(TextOutput) + Speak(TextOutput) Init() \ No newline at end of file