7.5: Windows support

This commit is contained in:
sarah committed 2026-10-09 14:00:38 +02:00
1 parent 4a52120b1a
commit a6a5b28631
6 files changed
+19 -14

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
Title = "SaraSortd Config" Title = "SaraSortd Config"
Version = "7.4" Version = "7.5"
SafeMode = 1 SafeMode = 1
SilentMode = 0 SilentMode = 0
SortTimer = 1 SortTimer = 1
+1 -1
View File
@@ -1,5 +1,5 @@
Title = "Unset" Title = "Unset"
Version = "7.4" Version = "7.5"
ParentDir = "Unset" ParentDir = "Unset"
SortDirs = 0 SortDirs = 0
+1 -1
View File
@@ -1,5 +1,5 @@
Title = "Unset" Title = "Unset"
Version = "7.4" Version = "7.5"
LastFile = "Unset" LastFile = "Unset"
ParentDir = "Unset" ParentDir = "Unset"
ValidInputDirs = ["*"] ValidInputDirs = ["*"]
+4 -4
View File
@@ -1,6 +1,6 @@
<img align="center" src="https://git.srhtnin.garden/sarah/RepoAssets/raw/branch/main/SaraSortd/Banners/SaraSortd.png" width="100%" alt="SaraSortd: a file and directory sorting daemon built with python."/> <img align="center" src="https://git.srhtnin.garden/sarah/RepoAssets/raw/branch/main/SaraSortd/Banners/SaraSortd.png" width="100%" alt="SaraSortd: a file and directory sorting daemon built with python."/>
(Version = "7.4") (Version = "7.5")
It's made by Sarah, hence the name. :3 It's made by Sarah, hence the name. :3
@@ -58,7 +58,7 @@ Here's a step-by-step tutorial (in case you don't want to watch the video).
``` ```
Title = "SaraSortd Config" # NOTE: Do not change the title. This is so that the program knows which config file is which. Title = "SaraSortd Config" # NOTE: Do not change the title. This is so that the program knows which config file is which.
Version = "7.4" # Just the version number for the config file. Version = "7.5" # Just the version number for the config file.
SafeMode = 1 # If SaraSortd should stop if an error with the config appears. 1 is stop, 0 is continue. SafeMode = 1 # If SaraSortd should stop if an error with the config appears. 1 is stop, 0 is continue.
@@ -170,7 +170,7 @@ The output directory config references the SaraSortd config (GlobalConf.toml). T
``` ```
Title = "Unset" # NOTE: Do not change the title. This is so that the program knows which config file is which. Title = "Unset" # NOTE: Do not change the title. This is so that the program knows which config file is which.
Version = "7.4" # The version number of the config. Version = "7.5" # The version number of the config.
LastFile = "Unset" # The last file that was sorted to this directory. It gets automatically updated whenever a file gets sorted to this directory. LastFile = "Unset" # The last file that was sorted to this directory. It gets automatically updated whenever a file gets sorted to this directory.
@@ -226,7 +226,7 @@ Overwrite = 1 # Whether this specific file type can be overwritten by others of
``` ```
Title = "Unset" # NOTE: Do not change the title. This is so that the program knows which config file is which. Title = "Unset" # NOTE: Do not change the title. This is so that the program knows which config file is which.
Version = "7.4" Version = "7.5"
ParentDir = "Unset" # The name of this directory. It gets automatically updated when this config gets copied to an output directory. ParentDir = "Unset" # The name of this directory. It gets automatically updated when this config gets copied to an output directory.
+12 -7
View File
@@ -6,7 +6,7 @@ import shutil
import time import time
import toml import toml
# Version = "7.4" # Version = "7.5"
ConfPath = "./GlobalConf.toml" ConfPath = "./GlobalConf.toml"
@@ -235,16 +235,21 @@ def ConfFolder(PathText):
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(ConfPath)), PathText)) return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(ConfPath)), PathText))
def Slashes(Path):
# Windows paths use "\\" (and configs may mix both); compare and name them with "/" only.
return Path.replace("\\", "/")
def FlatName(Path): def FlatName(Path):
# A directory's name for files kept outside it: its path below RootDir (or its whole path), "/" turned into "_". # A directory's name for files kept outside it: its path below RootDir (or its whole path), "/" turned into "_".
# E.G: "%RootDir%/Pictures/Cats" becomes "Pictures_Cats". # E.G: "%RootDir%/Pictures/Cats" becomes "Pictures_Cats". On Windows a drive's ":" is dropped (not allowed in names).
Root = ParsePath(ConfDirs.get("RootDir", "")).rstrip("/") Root = Slashes(ParsePath(ConfDirs.get("RootDir", ""))).rstrip("/")
Path = Path.rstrip("/") Path = Slashes(Path).rstrip("/")
if Root and Path.startswith(Root + "/"): if Root and Path.startswith(Root + "/"):
Relative = Path[len(Root) + 1:] Relative = Path[len(Root) + 1:]
else: else:
Relative = Path.strip("/") or os.path.basename(Path) Relative = Path.strip("/") or os.path.basename(Path)
return Relative.replace("/", "_") return Relative.replace(":", "").replace("/", "_")
def CentralConf(Path, Kind): def CentralConf(Path, Kind):
@@ -252,7 +257,7 @@ def CentralConf(Path, Kind):
# [DirConfs] names a file per directory ("dir" = "file", or "dir" = { In = "file", Out = "file" }), # [DirConfs] names a file per directory ("dir" = "file", or "dir" = { In = "file", Out = "file" }),
# and DirConfDir holds the configs of every directory [DirConfs] doesn't name. None means inside the directory. # and DirConfDir holds the configs of every directory [DirConfs] doesn't name. None means inside the directory.
for Key, Value in (Conf.get("DirConfs") or {}).items(): for Key, Value in (Conf.get("DirConfs") or {}).items():
if ParsePath(Key).rstrip("/") == Path.rstrip("/"): if Slashes(ParsePath(Key)).rstrip("/") == Slashes(Path).rstrip("/"):
if isinstance(Value, dict): if isinstance(Value, dict):
Value = Value.get(Kind) Value = Value.get(Kind)
if Value: if Value:
@@ -301,7 +306,7 @@ def Clone(Source, Destination, NewName, Delete = False):
with open(FileHistoryPath, "w", encoding = "utf-8") as HistoryFile: with open(FileHistoryPath, "w", encoding = "utf-8") as HistoryFile:
toml.dump(HistoryFileData, HistoryFile) toml.dump(HistoryFileData, HistoryFile)
os.rename(Source, os.path.join(Destination, NewName)) os.replace(Source, os.path.join(Destination, NewName)) # overwrites on Windows too, like rename on Linux
return return
Dir(Destination, Output = False, CopyConf = False) Dir(Destination, Output = False, CopyConf = False)
Binary file not shown.