From 2cc72b1730e5786fabe8fd95c2fa586a0137bccd Mon Sep 17 00:00:00 2001 From: Sarahtonin Date: Sun, 10 May 2026 21:42:21 +0200 Subject: [PATCH] Added unzipping function, but haven't tested it yet. --- GlobalConf.toml | 2 +- InputDirConf.toml | 2 +- OutputDirConf.toml | 3 ++- README.md | 10 ++++++---- SaraSortd.py | 15 ++++++++++++++- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/GlobalConf.toml b/GlobalConf.toml index f4dfd59..b8106fd 100644 --- a/GlobalConf.toml +++ b/GlobalConf.toml @@ -1,5 +1,5 @@ Title = "SaraSortd Config" -Version = "6.3" +Version = "6.4" SafeMode = 1 SilentMode = 0 CheckInput = 5 diff --git a/InputDirConf.toml b/InputDirConf.toml index 5567027..62dde71 100644 --- a/InputDirConf.toml +++ b/InputDirConf.toml @@ -1,5 +1,5 @@ Title = "Unset" -Version = "6.3" +Version = "6.4" ParentDir = "Unset" SortDirs = 0 diff --git a/OutputDirConf.toml b/OutputDirConf.toml index 9354b09..81e9965 100644 --- a/OutputDirConf.toml +++ b/OutputDirConf.toml @@ -1,10 +1,11 @@ Title = "Unset" -Version = "6.3" +Version = "6.4" LastFile = "Unset" ParentDir = "Unset" ValidInputDirs = ["*"] FileLimit = 0 DeleteOrg = 1 +Unzip = 1 [[Files]] Pattern = "*" diff --git a/README.md b/README.md index b395749..ff85bd7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ SaraSortd: a file and directory sorting daemon built with python. -(Version = "6.3") +(Version = "6.4") 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. -Version = "6.3" # Just the version number for the config file. +Version = "6.4" # 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. @@ -158,7 +158,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. -Version = "6.3" # The version number of the config. +Version = "6.4" # 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. @@ -170,6 +170,8 @@ FileLimit = 0 # The max limit of files a directory can have. If this is 0, then DeleteOrg = 1 # If SaraSortd should delete the original file or not. If this is 1, then sorted files will be 'moved' to an output directory. If not, they will be 'copied' to an output directory. +Unzip = 1 # If this output directory should unzip zip files that get sent here. + [[Files]] # The double brackets means that you can add multiple types of files to be sorted here. Just copy [[Files]] and all the parameters under it, and paste it under or over this section, then you may change the values of the new parameters. E.G: # [[Files]] @@ -209,7 +211,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. -Version = "6.3" +Version = "6.4" ParentDir = "Unset" # The name of this directory. It gets automatically updated when this config gets copied to an output directory. diff --git a/SaraSortd.py b/SaraSortd.py index 8251f42..efadf5c 100644 --- a/SaraSortd.py +++ b/SaraSortd.py @@ -6,7 +6,7 @@ import shutil import time import toml -# Version = "6.3" +# Version = "6.4" ConfPath = "./GlobalConf.toml" @@ -307,6 +307,19 @@ def DecideNewPath(FilePath): FileLimitConf = GetConf("FileLimit", OutDirConfPath) + if GetConf("Unzip", OutDirConfPath) == 1: + ZipTypes = ["zip", "tar.gz", "bz2"] + for OutputFile in os.listdir(Output): + if OutputFile.startswith("."): + continue + + for ZipType in ZipTypes: + if OutputFile.lower().endswith(ZipType): + shutil.unpack_archive(f"{Output}/{OutputFile}", Output, ZipType) + TextOutput = Parse(String = ConfLog["Unzipping"], VarCall = f"{Output}/{OutputFile}") + LogWrite(TextOutput) + Speak(TextOutput) + if FileLimitConf > 0: for OutputFile in os.listdir(Output): if OutputFile.startswith("."):