mirror of
https://git.srhtnin.garden/sarah/SaraSortd.git
synced 2026-10-14 10:48:11 +02:00
Added delete parameter to dirconf.
This commit is contained in:
1 parent
9fbdec9120
commit
d68550d0a9
4 files changed
+22
-22
No files matched your search
+3
-1
@@ -142,7 +142,9 @@ ParentDir = "Unset" # The name of this directory. It gets automatically updated
|
||||
|
||||
ValidInputDirs = ["*"] # Directories that are valid for sorting. Basically, if a file is from one of these directories, they can be sorted here. * is a wildcard; ? is a one-character wilcard. E.G: if "ValidInputDirs = ["/TestDir/*"]" any file from any directory in "/TestDir" will be allowed to be sorted here.
|
||||
|
||||
FileLimit = 0
|
||||
FileLimit = 0 # The max limit of files a directory can have. If this is 0, then there's no limit.
|
||||
|
||||
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.
|
||||
|
||||
[[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:
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
Title = "SaraSortd Config"
|
||||
SafeMode = 1
|
||||
SilentMode = 0
|
||||
CheckInput = 3
|
||||
CheckInput = 10
|
||||
DotFiles = 0
|
||||
Logging = 1
|
||||
OverwriteDirConf = 0
|
||||
|
||||
@@ -3,6 +3,7 @@ LastFile = "Unset"
|
||||
ParentDir = "Unset"
|
||||
ValidInputDirs = ["*"]
|
||||
FileLimit = 0
|
||||
DeleteOrg = 1
|
||||
|
||||
[[Files]]
|
||||
Pattern = "*"
|
||||
|
||||
+17
-20
@@ -266,7 +266,6 @@ def DecideNewPath(FilePath):
|
||||
if not os.path.exists(DirConfPath) or not InputDirValid:
|
||||
continue
|
||||
|
||||
|
||||
OutputFiles = 0
|
||||
|
||||
FileLimitConf = GetConf("FileLimit", DirConfPath)
|
||||
@@ -365,37 +364,37 @@ def DecideNewPath(FilePath):
|
||||
def Sort(FilePath):
|
||||
NewPath = DecideNewPath(FilePath)
|
||||
|
||||
NewDirPath = os.path.dirname(NewPath)
|
||||
NewName = os.path.basename(NewPath)
|
||||
|
||||
if (GetConf("DeleteOrg", f"{NewDirPath}/{Parse(String = ConfNames['DirConfName'], Parent = (os.path.basename(NewDirPath)))}.toml") == 1):
|
||||
Delete = True
|
||||
|
||||
else:
|
||||
Delete = False
|
||||
|
||||
if NewPath is None:
|
||||
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
||||
NewName = os.path.basename(FilePath)
|
||||
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, True)
|
||||
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, Delete)
|
||||
|
||||
TextOutput = Parse(String = ConfLog["NotSorted"], VarCall = FilePath)
|
||||
LogWrite(TextOutput)
|
||||
Speak(TextOutput)
|
||||
return
|
||||
|
||||
NewDirPath = os.path.dirname(NewPath)
|
||||
NewName = os.path.basename(NewPath)
|
||||
|
||||
try:
|
||||
Clone(FilePath, NewDirPath, NewName, True)
|
||||
UpdateConf(
|
||||
f"{NewDirPath}/{Parse(String = ConfNames['DirConfName'], Parent = os.path.basename(NewDirPath))}.toml",
|
||||
"LastFile",
|
||||
NewName,
|
||||
)
|
||||
Clone(FilePath, NewDirPath, NewName, Delete)
|
||||
UpdateConf(f"{NewDirPath}/{Parse(String = ConfNames['DirConfName'], Parent = os.path.basename(NewDirPath))}.toml", "LastFile", NewName)
|
||||
|
||||
TextOutput = Parse(
|
||||
String = ConfLog["Sorted"], VarCall = f"{FilePath} to {NewDirPath}/{NewName}"
|
||||
)
|
||||
TextOutput = Parse(String = ConfLog["Sorted"], VarCall = f"{FilePath} to {NewDirPath}/{NewName}")
|
||||
LogWrite(TextOutput)
|
||||
Speak(TextOutput)
|
||||
|
||||
except Exception:
|
||||
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
||||
NewName = os.path.basename(NewPath)
|
||||
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, True)
|
||||
Clone(FilePath, Parse(String = ConfDirs["FailedDir"]), NewName, Delete)
|
||||
|
||||
TextOutput = Parse(String = ConfLog["NotSorted"], VarCall = FilePath)
|
||||
LogWrite(TextOutput)
|
||||
@@ -419,7 +418,7 @@ def Init():
|
||||
Output = Parse(String = Output, Parent = os.path.basename(os.path.dirname(Output)))
|
||||
Dir(Output)
|
||||
|
||||
DirConfPath = f"{os.path.join(Output, Parse(String = ConfNames["DirConfName"], Parent = os.path.basename(Output)))}.toml"
|
||||
DirConfPath = f"{Output}/{Parse(String = ConfNames["DirConfName"], Parent = os.path.basename(Output))}.toml"
|
||||
ConfData = toml.load(DirConfPath)
|
||||
|
||||
for Item in ConfData.get("Files", []):
|
||||
@@ -444,9 +443,7 @@ def Init():
|
||||
Speak(TextOutput)
|
||||
|
||||
else:
|
||||
print(
|
||||
"NO CONFIG FOUND! Make sure the 'Config.toml' is in the same directory as 'SaraSortd.py'"
|
||||
)
|
||||
print("NO CONFIG FOUND! Make sure the 'Config.toml' is in the same directory as 'SaraSortd.py'")
|
||||
|
||||
|
||||
def Main():
|
||||
@@ -459,7 +456,7 @@ def Main():
|
||||
continue
|
||||
|
||||
for FileName in os.listdir(InputPath):
|
||||
FilePath = os.path.join(InputPath, FileName)
|
||||
FilePath = f"{InputPath}/{FileName}"
|
||||
|
||||
if os.path.isfile(FilePath):
|
||||
FileName = os.path.basename(FilePath)
|
||||
|
||||
Reference in new issue
Block a user