mirror of
https://git.srhtnin.garden/sarah/SaraSortd.git
synced 2026-10-14 02:38:12 +02:00
7.1: optional ValidInputDirs per [[Files]] entry
An output directory can now take different patterns from different input directories. Entries without it behave as before. Also fixes the README's outdated Names section (InDirConfName/OutDirConfName), NextNum and LogFileName. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
16e6b7196e
commit
78216fc352
5 files changed
+36
-13
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
Title = "SaraSortd Config"
|
Title = "SaraSortd Config"
|
||||||
Version = "7.0"
|
Version = "7.1"
|
||||||
SafeMode = 1
|
SafeMode = 1
|
||||||
SilentMode = 0
|
SilentMode = 0
|
||||||
SortTimer = 1
|
SortTimer = 1
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
Title = "Unset"
|
Title = "Unset"
|
||||||
Version = "7.0"
|
Version = "7.1"
|
||||||
ParentDir = "Unset"
|
ParentDir = "Unset"
|
||||||
SortDirs = 0
|
SortDirs = 0
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
Title = "Unset"
|
Title = "Unset"
|
||||||
Version = "7.0"
|
Version = "7.1"
|
||||||
LastFile = "Unset"
|
LastFile = "Unset"
|
||||||
ParentDir = "Unset"
|
ParentDir = "Unset"
|
||||||
ValidInputDirs = ["*"]
|
ValidInputDirs = ["*"]
|
||||||
|
|||||||
@@ -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.0")
|
(Version = "7.1")
|
||||||
|
|
||||||
|
|
||||||
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.0" # Just the version number for the config file.
|
Version = "7.1" # 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.
|
||||||
|
|
||||||
@@ -73,13 +73,13 @@ Logging = 1 # If SaraSortd's logging system should be active. If this is 0, noth
|
|||||||
OverwriteDirConf = 0 # If SaraSortd should overwrite directory configs with the config templates. 0 is no, 1 is yes.
|
OverwriteDirConf = 0 # If SaraSortd should overwrite directory configs with the config templates. 0 is no, 1 is yes.
|
||||||
|
|
||||||
[Variables] # Only use these in config files, not the actual file names themselves.
|
[Variables] # Only use these in config files, not the actual file names themselves.
|
||||||
NextNum = "*" # The next available number. If 1 already exists, 2 will be used.
|
NextNum = "!" # The next available number. If 1 already exists, 2 will be used.
|
||||||
|
|
||||||
NextChar = "&" # The next available character. If A already exists, B will be used.
|
NextChar = "&" # The next available character. If A already exists, B will be used.
|
||||||
|
|
||||||
Parent = "@" # The name of the parent directory.
|
Parent = "@" # The name of the parent directory.
|
||||||
|
|
||||||
OrgFileName = "\~" # The original name of the sorted file. If "blahblah.txt" gets sorted, "~" would be equal to "blahblah".
|
OrgFileName = "~" # The original name of the sorted file. If "blahblah.txt" gets sorted, "~" would be equal to "blahblah".
|
||||||
|
|
||||||
OrgFileType = "^" # The original file type of the sorted file. If "example.png" gets sorted, "^" would be equal to ".png".
|
OrgFileType = "^" # The original file type of the sorted file. If "example.png" gets sorted, "^" would be equal to ".png".
|
||||||
|
|
||||||
@@ -109,9 +109,11 @@ LogDir = "%RootDir%/.Logs" # Where log files from SaraSortd go.
|
|||||||
FailedDir ="%RootDir%/.Failed" # For files that failed to be sorted.
|
FailedDir ="%RootDir%/.Failed" # For files that failed to be sorted.
|
||||||
|
|
||||||
[Names]
|
[Names]
|
||||||
LogFileName = "[y].[m].[d]._*" # Name for log files.
|
LogFileName = "[y].[m].[d]" # Name for log files.
|
||||||
|
|
||||||
DirConfName = ".@Config" # Name for config files for directories.
|
InDirConfName = ".@Config" # Name for config files for input directories.
|
||||||
|
|
||||||
|
OutDirConfName = ".@Config" # Name for config files for output directories. If a directory is both an input and an output and both names are the same, it uses one config file for both.
|
||||||
|
|
||||||
FileHistoryName = ".@History" # Name for file history files. This keeps track of sorted files if an input and output are the same directory.
|
FileHistoryName = ".@History" # Name for file history files. This keeps track of sorted files if an input and output are the same directory.
|
||||||
|
|
||||||
@@ -158,7 +160,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.0" # The version number of the config.
|
Version = "7.1" # 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.
|
||||||
|
|
||||||
@@ -202,6 +204,8 @@ NextChar = "A" # Used to keep track of the next available letter for file names.
|
|||||||
CaseSensitive = 0 # Whether this "Pattern" is case-sensitive or not. 1 is yes, 0 is no. E.G: if CaseSensitive = 1 and this "Pattern" is "*.PNG", a file named "picture.png" won't get sorted to this directory. If CaseSensitive = 0 and this "Pattern" is "*.PNG", a file named "picture.png" *will* get sorted to this directory.
|
CaseSensitive = 0 # Whether this "Pattern" is case-sensitive or not. 1 is yes, 0 is no. E.G: if CaseSensitive = 1 and this "Pattern" is "*.PNG", a file named "picture.png" won't get sorted to this directory. If CaseSensitive = 0 and this "Pattern" is "*.PNG", a file named "picture.png" *will* get sorted to this directory.
|
||||||
|
|
||||||
Overwrite = 1 # Whether this specific file type can be overwritten by others of the same type. 0 is no, 1 is yes.
|
Overwrite = 1 # Whether this specific file type can be overwritten by others of the same type. 0 is no, 1 is yes.
|
||||||
|
|
||||||
|
# ValidInputDirs = ["%RootDir%/Downloads"] # Optional (since 7.1). Like the ValidInputDirs above, but only for this [[Files]] entry, so different input directories can send different file types here. Without it, this entry takes files from every input directory the ValidInputDirs above allows.
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -212,7 +216,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.0"
|
Version = "7.1"
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
+21
-2
@@ -6,7 +6,7 @@ import shutil
|
|||||||
import time
|
import time
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
# Version = "7.0"
|
# Version = "7.1"
|
||||||
|
|
||||||
ConfPath = "./GlobalConf.toml"
|
ConfPath = "./GlobalConf.toml"
|
||||||
|
|
||||||
@@ -276,6 +276,21 @@ def LogWrite(Text):
|
|||||||
File.write(f"{Parse(String = ConfLog['All'], Path = ConfPath)}{Text}\n")
|
File.write(f"{Parse(String = ConfLog['All'], Path = ConfPath)}{Text}\n")
|
||||||
|
|
||||||
|
|
||||||
|
def FileInputValid(File, FilePath, ParentName):
|
||||||
|
# A [[Files]] entry can have its own ValidInputDirs (since 7.1), so one output directory can take
|
||||||
|
# different patterns from different input directories. Without one, the entry takes files from
|
||||||
|
# every input directory the output directory's own ValidInputDirs allows.
|
||||||
|
ValidInputDirs = File.get("ValidInputDirs")
|
||||||
|
if ValidInputDirs is None:
|
||||||
|
return True
|
||||||
|
|
||||||
|
for ValidInputDir in ValidInputDirs:
|
||||||
|
if fnmatch.fnmatchcase(os.path.dirname(FilePath), Parse(String = ValidInputDir, Parent = ParentName)):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def DecideNewPath(FilePath):
|
def DecideNewPath(FilePath):
|
||||||
UnsortedFile = os.path.basename(FilePath)
|
UnsortedFile = os.path.basename(FilePath)
|
||||||
|
|
||||||
@@ -287,7 +302,8 @@ def DecideNewPath(FilePath):
|
|||||||
OutDirConfName = Parse(String = ConfNames["OutDirConfName"], Path = ConfPath, Parent = ParentName)
|
OutDirConfName = Parse(String = ConfNames["OutDirConfName"], Path = ConfPath, Parent = ParentName)
|
||||||
OutDirConfPath = f"{Output}/{OutDirConfName}.toml"
|
OutDirConfPath = f"{Output}/{OutDirConfName}.toml"
|
||||||
|
|
||||||
ValidInputDirs = GetConf("ValidInputDirs", OutDirConfPath)
|
ValidInputDirs = GetConf("ValidInputDirs", OutDirConfPath) or []
|
||||||
|
InputDirValid = False
|
||||||
|
|
||||||
for ValidInputDir in ValidInputDirs:
|
for ValidInputDir in ValidInputDirs:
|
||||||
ValidInputDir = Parse(String = ValidInputDir, Parent = GetConf("ParentDir", OutDirConfPath))
|
ValidInputDir = Parse(String = ValidInputDir, Parent = GetConf("ParentDir", OutDirConfPath))
|
||||||
@@ -323,6 +339,9 @@ def DecideNewPath(FilePath):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
for File in FileConf:
|
for File in FileConf:
|
||||||
|
if not FileInputValid(File, FilePath, ParentName):
|
||||||
|
continue
|
||||||
|
|
||||||
Pattern = File["Pattern"]
|
Pattern = File["Pattern"]
|
||||||
|
|
||||||
TextOutput = Parse(String = ConfLog["MatchPattern"], VarCall = f"{UnsortedFile} against {Pattern}")
|
TextOutput = Parse(String = ConfLog["MatchPattern"], VarCall = f"{UnsortedFile} against {Pattern}")
|
||||||
|
|||||||
Reference in new issue
Block a user