From aef32f6f3b61535db6c802d60cc541992d0a2bdf Mon Sep 17 00:00:00 2001 From: SRHTNIN Date: Wed, 7 Oct 2026 22:50:11 +0200 Subject: [PATCH] Update NextNum/NextChar by entry position, not by Pattern Two [[Files]] entries can now share a Pattern (with different ValidInputDirs), and the counter of the first one was bumped for both. Co-Authored-By: Claude Opus 5.5 --- SaraSortd.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/SaraSortd.py b/SaraSortd.py index e30e0d6..bb24df5 100644 --- a/SaraSortd.py +++ b/SaraSortd.py @@ -338,7 +338,7 @@ def DecideNewPath(FilePath): if not FileConf: continue - for File in FileConf: + for FileIndex, File in enumerate(FileConf): if not FileInputValid(File, FilePath, ParentName): continue @@ -368,10 +368,8 @@ def DecideNewPath(FilePath): NewNum = str((int(File["NextNum"]) + 1)).rjust(Width, "0") print(File["NextNum"],"=>",NewNum) - for Item in ConfData.get("Files", []): - if Item.get("Pattern") == File["Pattern"]: - Item["NextNum"] = NewNum - break + # By position: two entries can share a Pattern (with different ValidInputDirs). + ConfData["Files"][FileIndex]["NextNum"] = NewNum with open(OutDirConfPath, "w", encoding="utf-8") as ConfFile: toml.dump(ConfData, ConfFile) @@ -403,10 +401,7 @@ def DecideNewPath(FilePath): ConfData = toml.load(OutDirConfPath) - for Item in ConfData.get("Files", []): - if Item.get("Pattern") == File["Pattern"]: - Item["NextChar"] = NewChar - break + ConfData["Files"][FileIndex]["NextChar"] = NewChar with open(OutDirConfPath, "w", encoding="utf-8") as ConfFile: toml.dump(ConfData, ConfFile)