mirror of
https://git.srhtnin.garden/sarah/SaraSortd.git
synced 2026-10-14 10:48:11 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd00cf0780 | ||
|
|
51c557d228 | ||
|
|
e91ce510fc | ||
|
|
d68550d0a9 | ||
|
|
9fbdec9120 | ||
|
|
0b54a729ff | ||
|
|
a3bc726086 | ||
|
|
739f91a5bf | ||
|
|
fc6f9bd399 | ||
|
|
077cbbb2c1 | ||
|
|
ffd95fdfce | ||
|
|
49b5549b1d | ||
|
|
cbf1a4049c |
No files matched your search
+45
-3
@@ -1,11 +1,48 @@
|
|||||||
# SaraSortd
|
# SaraSortd
|
||||||
|
|
||||||
A python daemon that can automatically sort your files to your liking without using AI.
|
A python daemon that can automatically sort your files to your liking without using AI.
|
||||||
|
|
||||||
It's made by Sarah, hence the name. :3
|
It's made by Sarah, hence the name. :3
|
||||||
|
|
||||||
|
The versioning for SaraSortd is like so: the first number going up means that your
|
||||||
|
previous config files won't work anymore with the new SaraSortd.py.
|
||||||
|
|
||||||
|
The second number going up means that something has been changed, but you can still
|
||||||
|
use your old config files with SaraSortd.py.
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
SaraSortd is for people who don't want to manually sort files, people who want to organise files, and people who want an automatic naming standard for their files.
|
||||||
|
|
||||||
|
Example use-cases:
|
||||||
|
|
||||||
|
- Sorting log files from multiple programs into one directory.
|
||||||
|
|
||||||
|
- Sorting downloaded github repositories to a directory for your IDE.
|
||||||
|
|
||||||
|
- Regularly cloning important files into a backup directory.
|
||||||
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
|
python
|
||||||
|
|
||||||
toml: Use ```pip install toml``` to install toml.
|
toml: Use ```pip install toml``` to install toml.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
Here's an [installation video.](https://youtu.be/ZMIaOhZA0kE).
|
||||||
|
Here's a step-by-step tutorial (in case you don't want to watch the video).
|
||||||
|
|
||||||
|
1. Install ZIP-file.
|
||||||
|
2. Unzip ZIP-file wherever you want the program to live.
|
||||||
|
3. Navigate to the new SaraSortd directory in your terminal.
|
||||||
|
4. Edit your config files to your liking.
|
||||||
|
5. Run ```python SaraSortd.py``` to run the program. (This will make new directories for you.)
|
||||||
|
6. Edit your output directories' configs.
|
||||||
|
|
||||||
## Config explanation
|
## Config explanation
|
||||||
|
|
||||||
### SaraSortd Config (Config.toml)
|
### SaraSortd Config (Config.toml)
|
||||||
@@ -66,6 +103,8 @@ LogFileName = "[y].[m].[d]._*" # Name for log files.
|
|||||||
|
|
||||||
DirConfName = ".@Config" # Name for config files for directories.
|
DirConfName = ".@Config" # Name for config files for directories.
|
||||||
|
|
||||||
|
FileHistoryName = ".@History" # Name for file history files. This keeps track of sorted files if an input and output are the same directory.
|
||||||
|
|
||||||
[Log]
|
[Log]
|
||||||
All = "[h]:[n]:[s] | " # What to put at the start of all lines in Log file.
|
All = "[h]:[n]:[s] | " # What to put at the start of all lines in Log file.
|
||||||
|
|
||||||
@@ -91,6 +130,7 @@ Unset = "Error: %% is not set." # When a value isn't set.
|
|||||||
# %% here is just the parameter who's value was either "Unset" or None. E.G: "RootDir".
|
# %% here is just the parameter who's value was either "Unset" or None. E.G: "RootDir".
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Output Directory Config (DirConfig.toml)
|
### Output Directory Config (DirConfig.toml)
|
||||||
|
|
||||||
The output directory config references the SaraSortd config (Config.toml). This means that you can, for example, use the character assigned to "NextNum" in Config.toml in this config (DirConfig.toml). This applies to all Variables in the SaraSortd config (Config.toml).
|
The output directory config references the SaraSortd config (Config.toml). This means that you can, for example, use the character assigned to "NextNum" in Config.toml in this config (DirConfig.toml). This applies to all Variables in the SaraSortd config (Config.toml).
|
||||||
@@ -104,7 +144,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.
|
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:
|
[[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:
|
||||||
|
|
||||||
@@ -128,9 +170,9 @@ Pattern = "*" # A pattern used to sort files to this directory. * is a wildcard;
|
|||||||
|
|
||||||
NewFileName = "~^" # A pattern for the new names of the files that get sorted to this directory from matching this "Pattern".
|
NewFileName = "~^" # A pattern for the new names of the files that get sorted to this directory from matching this "Pattern".
|
||||||
|
|
||||||
NextNum = 1 # Used to keep track of the next available number for file names. It gets automatically incremented when NextNum is used in NewFileName, and a file gets sorted to this directory and renamed.
|
NextNum = 1 # Used to keep track of the next available number for file names. If you have two of the character that represents NextNum (Found in Config.toml), you can stack them together to make 01 or 001 instead of 1. It gets automatically incremented when NextNum is used in NewFileName, and a file gets sorted to this directory and renamed.
|
||||||
|
|
||||||
NextChar = "A" # Used to keep track of the next available letter for file names. It gets automatically incremented (E.G: A into B) when NextChar is used in NewFileName, and a file gets sorted to this directory and renamed.
|
NextChar = "A" # Used to keep track of the next available letter for file names. It gets automatically incremented (E.G: A into B or AA into AB then AZ into BA) when NextChar is used in NewFileName, and a file gets sorted to this directory and renamed.
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -1,7 +1,7 @@
|
|||||||
Title = "SaraSortd Config"
|
Title = "SaraSortd Config"
|
||||||
SafeMode = 1
|
SafeMode = 1
|
||||||
SilentMode = 0
|
SilentMode = 0
|
||||||
CheckInput = 3
|
CheckInput = 5
|
||||||
DotFiles = 0
|
DotFiles = 0
|
||||||
Logging = 1
|
Logging = 1
|
||||||
OverwriteDirConf = 0
|
OverwriteDirConf = 0
|
||||||
@@ -21,7 +21,7 @@ Second = "[s]"
|
|||||||
VarCall = "%%"
|
VarCall = "%%"
|
||||||
|
|
||||||
[DirectoryPaths]
|
[DirectoryPaths]
|
||||||
RootDir = "Unset"
|
RootDir = "/home/sarah/TestDir"
|
||||||
InputDir = [ "%RootDir%/Input" ]
|
InputDir = [ "%RootDir%/Input" ]
|
||||||
OutputDir = [ "%RootDir%/Output" ]
|
OutputDir = [ "%RootDir%/Output" ]
|
||||||
LogDir = "%RootDir%/.Logs"
|
LogDir = "%RootDir%/.Logs"
|
||||||
@@ -30,12 +30,13 @@ FailedDir = "%RootDir%/.Failed"
|
|||||||
[Names]
|
[Names]
|
||||||
LogFileName = "[y].[m].[d]"
|
LogFileName = "[y].[m].[d]"
|
||||||
DirConfName = ".@Config"
|
DirConfName = ".@Config"
|
||||||
|
FileHistoryName = ".@History"
|
||||||
|
|
||||||
[Log]
|
[Log]
|
||||||
All = "[h]:[n]:[s] | "
|
All = "[h]:[n]:[s] | "
|
||||||
Start = "Started SaraSortd."
|
Start = "Started SaraSortd."
|
||||||
NotStart = "Error: Failed to start SaraSortd."
|
NotStart = "Error: Failed to start SaraSortd."
|
||||||
Stop = "\nStopped SaraSortd."
|
Stop = "Stopped SaraSortd.\n"
|
||||||
MatchPattern = "Checking %%."
|
MatchPattern = "Checking %%."
|
||||||
Sorted = "Sorted %%."
|
Sorted = "Sorted %%."
|
||||||
NotSorted = "Error: Failed to sort %%. No valid output directory."
|
NotSorted = "Error: Failed to sort %%. No valid output directory."
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ LastFile = "Unset"
|
|||||||
ParentDir = "Unset"
|
ParentDir = "Unset"
|
||||||
ValidInputDirs = ["*"]
|
ValidInputDirs = ["*"]
|
||||||
FileLimit = 0
|
FileLimit = 0
|
||||||
|
DeleteOrg = 1
|
||||||
|
|
||||||
[[Files]]
|
[[Files]]
|
||||||
Pattern = "*"
|
Pattern = "*"
|
||||||
|
|||||||
+124
-45
@@ -166,11 +166,11 @@ def Parse(
|
|||||||
ConfVars["OrgFileName"]: str(OrgFileName),
|
ConfVars["OrgFileName"]: str(OrgFileName),
|
||||||
ConfVars["OrgFileType"]: str(OrgFileType),
|
ConfVars["OrgFileType"]: str(OrgFileType),
|
||||||
ConfVars["Year"]: str(Now.year),
|
ConfVars["Year"]: str(Now.year),
|
||||||
ConfVars["Month"]: str(Now.month),
|
ConfVars["Month"]: str(Now.month).rjust(2, "0"),
|
||||||
ConfVars["Day"]: str(Now.day),
|
ConfVars["Day"]: str(Now.day).rjust(2, "0"),
|
||||||
ConfVars["Hour"]: str(Now.hour),
|
ConfVars["Hour"]: str(Now.hour).rjust(2, "0"),
|
||||||
ConfVars["Minute"]: str(Now.minute),
|
ConfVars["Minute"]: str(Now.minute).rjust(2, "0"),
|
||||||
ConfVars["Second"]: str(Now.second),
|
ConfVars["Second"]: str(Now.second).rjust(2, "0"),
|
||||||
ConfVars["VarCall"]: str(VarCall),
|
ConfVars["VarCall"]: str(VarCall),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +188,23 @@ def Parse(
|
|||||||
|
|
||||||
|
|
||||||
def Clone(Source, Destination, NewName, Delete = False):
|
def Clone(Source, Destination, NewName, Delete = False):
|
||||||
|
if (os.path.dirname(Source) == Destination):
|
||||||
|
FileHistoryPath = f"{Destination}/{Parse(ConfNames["FileHistoryName"], Parent = os.path.basename(Destination))}.toml"
|
||||||
|
print("FileHistoryPath:",FileHistoryPath)
|
||||||
|
|
||||||
|
if not os.path.exists(FileHistoryPath):
|
||||||
|
with open(FileHistoryPath, "w", encoding = "utf-8") as HistoryFile:
|
||||||
|
toml.dump({"Title": f"{os.path.basename(Destination)} History", "History": []}, HistoryFile)
|
||||||
|
|
||||||
|
HistoryFileData = toml.load(FileHistoryPath)
|
||||||
|
if (NewName not in HistoryFileData["History"]):
|
||||||
|
HistoryFileData["History"].append(NewName)
|
||||||
|
with open(FileHistoryPath, "w", encoding = "utf-8") as HistoryFile:
|
||||||
|
toml.dump(HistoryFileData, HistoryFile)
|
||||||
|
|
||||||
|
os.rename(Source, os.path.join(Destination, NewName))
|
||||||
|
return
|
||||||
|
|
||||||
Dir(Destination, Output = False, CopyConf = False)
|
Dir(Destination, Output = False, CopyConf = False)
|
||||||
shutil.copy2(Source, Destination)
|
shutil.copy2(Source, Destination)
|
||||||
|
|
||||||
@@ -266,7 +283,6 @@ def DecideNewPath(FilePath):
|
|||||||
if not os.path.exists(DirConfPath) or not InputDirValid:
|
if not os.path.exists(DirConfPath) or not InputDirValid:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
OutputFiles = 0
|
OutputFiles = 0
|
||||||
|
|
||||||
FileLimitConf = GetConf("FileLimit", DirConfPath)
|
FileLimitConf = GetConf("FileLimit", DirConfPath)
|
||||||
@@ -302,30 +318,62 @@ def DecideNewPath(FilePath):
|
|||||||
if Match:
|
if Match:
|
||||||
NewFileName = File["NewFileName"]
|
NewFileName = File["NewFileName"]
|
||||||
|
|
||||||
NewFileName = Parse(
|
NewFileName = Parse(String = NewFileName, Path = DirConfPath, OrgFile = UnsortedFile, NextNum = File["NextNum"], NextChar = File["NextChar"], Parent = ParentName)
|
||||||
String = NewFileName,
|
|
||||||
Path = DirConfPath,
|
|
||||||
OrgFile = UnsortedFile,
|
|
||||||
NextNum = File["NextNum"],
|
|
||||||
NextChar = File["NextChar"],
|
|
||||||
Parent = ParentName,
|
|
||||||
)
|
|
||||||
|
|
||||||
if File["Overwrite"] == 0 and os.path.exists(os.path.join(Output, NewFileName)):
|
if File["Overwrite"] == 0 and os.path.exists(os.path.join(Output, NewFileName)):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if ConfVars["NextNum"] in NewFileName:
|
if ConfVars["NextNum"] in File["NewFileName"]:
|
||||||
UpdateConf(
|
ConfData = toml.load(DirConfPath)
|
||||||
DirConfPath,
|
|
||||||
"NextNum",
|
|
||||||
(int(GetConf("NextNum", DirConfPath)) + 1),
|
|
||||||
)
|
|
||||||
|
|
||||||
if ConfVars["NextChar"] in NewFileName:
|
NewNum = (int(File["NextNum"]) + 1)
|
||||||
CurrentChar = GetConf("NextChar", DirConfPath)
|
|
||||||
if CurrentChar and len(CurrentChar) == 1 and CurrentChar.isalpha():
|
for Item in ConfData.get("Files", []):
|
||||||
NewChar = chr(((ord(CurrentChar.upper()) - 65 + 1) % 26) + 65)
|
if Item.get("Pattern") == File["Pattern"]:
|
||||||
UpdateConf(DirConfPath, "NextChar", NewChar)
|
Item["NextNum"] = NewNum
|
||||||
|
break
|
||||||
|
|
||||||
|
with open(DirConfPath, "w", encoding="utf-8") as ConfFile:
|
||||||
|
toml.dump(ConfData, ConfFile)
|
||||||
|
|
||||||
|
TextOutput = Parse(String = ConfLog["ValueSet"], VarCall = f"NextChar to {NewNum}")
|
||||||
|
LogWrite(TextOutput)
|
||||||
|
Speak(TextOutput)
|
||||||
|
|
||||||
|
if ConfVars["NextChar"] in File["NewFileName"]:
|
||||||
|
CurrentChar = File["NextChar"]
|
||||||
|
CurrentChar = CurrentChar.upper()
|
||||||
|
Result = list(CurrentChar)
|
||||||
|
|
||||||
|
Count = len(Result) - 1
|
||||||
|
|
||||||
|
while Count >= 0:
|
||||||
|
if Result[Count] == "Z":
|
||||||
|
Result[Count] = "A"
|
||||||
|
Count -= 1
|
||||||
|
|
||||||
|
else:
|
||||||
|
Result[Count] = chr(ord(Result[Count]) + 1)
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
Result.insert(0, "A")
|
||||||
|
|
||||||
|
NewChar = "".join(Result)
|
||||||
|
|
||||||
|
ConfData = toml.load(DirConfPath)
|
||||||
|
|
||||||
|
for Item in ConfData.get("Files", []):
|
||||||
|
if Item.get("Pattern") == File["Pattern"]:
|
||||||
|
Item["NextChar"] = NewChar
|
||||||
|
break
|
||||||
|
|
||||||
|
with open(DirConfPath, "w", encoding="utf-8") as ConfFile:
|
||||||
|
toml.dump(ConfData, ConfFile)
|
||||||
|
|
||||||
|
TextOutput = Parse(String = ConfLog["ValueSet"], VarCall = f"NextChar to {NewChar}")
|
||||||
|
LogWrite(TextOutput)
|
||||||
|
Speak(TextOutput)
|
||||||
|
|
||||||
return f"{Output}/{NewFileName}"
|
return f"{Output}/{NewFileName}"
|
||||||
|
|
||||||
@@ -346,24 +394,24 @@ def Sort(FilePath):
|
|||||||
NewDirPath = os.path.dirname(NewPath)
|
NewDirPath = os.path.dirname(NewPath)
|
||||||
NewName = os.path.basename(NewPath)
|
NewName = os.path.basename(NewPath)
|
||||||
|
|
||||||
try:
|
if (GetConf("DeleteOrg", f"{NewDirPath}/{Parse(String = ConfNames['DirConfName'], Parent = (os.path.basename(NewDirPath)))}.toml") == 1):
|
||||||
Clone(FilePath, NewDirPath, NewName, True)
|
Delete = True
|
||||||
UpdateConf(
|
|
||||||
f"{NewDirPath}/{Parse(String = ConfNames['DirConfName'], Parent = os.path.basename(NewDirPath))}.toml",
|
|
||||||
"LastFile",
|
|
||||||
NewName,
|
|
||||||
)
|
|
||||||
|
|
||||||
TextOutput = Parse(
|
else:
|
||||||
String = ConfLog["Sorted"], VarCall = f"{FilePath} to {NewDirPath}/{NewName}"
|
Delete = False
|
||||||
)
|
|
||||||
|
try:
|
||||||
|
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}")
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
Dir(Parse(String = ConfDirs["FailedDir"]), Output = False, CopyConf = False)
|
||||||
NewName = os.path.basename(NewPath)
|
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)
|
TextOutput = Parse(String = ConfLog["NotSorted"], VarCall = FilePath)
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
@@ -383,10 +431,27 @@ def Init():
|
|||||||
InputDir = Parse(String = InputDir, Path = ConfPath, Parent = os.path.basename(os.path.dirname(InputDir)))
|
InputDir = Parse(String = InputDir, Path = ConfPath, Parent = os.path.basename(os.path.dirname(InputDir)))
|
||||||
Dir(InputDir, Output = False, CopyConf = False)
|
Dir(InputDir, Output = False, CopyConf = False)
|
||||||
|
|
||||||
|
for Output in ConfDirs["OutputDir"]:
|
||||||
|
Output = Parse(String = Output, Parent = os.path.basename(os.path.dirname(Output)))
|
||||||
|
Dir(Output)
|
||||||
|
|
||||||
|
DirConfPath = f"{Output}/{Parse(String = ConfNames["DirConfName"], Parent = os.path.basename(Output))}.toml"
|
||||||
|
ConfData = toml.load(DirConfPath)
|
||||||
|
|
||||||
|
for Item in ConfData.get("Files", []):
|
||||||
|
Character = re.escape(ConfVars["NextChar"])
|
||||||
|
Matches = re.findall(f"{Character}+", Item["NewFileName"])
|
||||||
|
Width = max((len(Match) for Match in Matches), default=0)
|
||||||
|
|
||||||
|
if Width > 0:
|
||||||
|
Item["NextChar"] = Item["NextChar"].upper().rjust(Width, "A")
|
||||||
|
|
||||||
|
with open(DirConfPath, "w", encoding = "utf-8") as ConfFile:
|
||||||
|
toml.dump(ConfData, ConfFile)
|
||||||
|
|
||||||
TextOutput = Parse(String = ConfLog["Start"], Path = ConfPath)
|
TextOutput = Parse(String = ConfLog["Start"], Path = ConfPath)
|
||||||
LogWrite(TextOutput)
|
LogWrite(TextOutput)
|
||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
Main()
|
Main()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -395,31 +460,45 @@ def Init():
|
|||||||
Speak(TextOutput)
|
Speak(TextOutput)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(
|
print("NO CONFIG FOUND! Make sure the 'Config.toml' is in the same directory as 'SaraSortd.py'")
|
||||||
"NO CONFIG FOUND! Make sure the 'Config.toml' is in the same directory as 'SaraSortd.py'"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def Main():
|
def Main():
|
||||||
for Output in ConfDirs["OutputDir"]:
|
|
||||||
Output = Parse(String = Output, Parent = os.path.basename(os.path.dirname(Output)))
|
|
||||||
Dir(Output)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
for Input in ConfDirs["InputDir"]:
|
for Input in ConfDirs["InputDir"]:
|
||||||
|
RecurseDir = False
|
||||||
|
|
||||||
InputPath = Parse(Input)
|
InputPath = Parse(Input)
|
||||||
|
|
||||||
if not os.path.exists(InputPath):
|
if not os.path.exists(InputPath):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
for Output in ConfDirs["OutputDir"]:
|
||||||
|
OutputPath = Parse(Output)
|
||||||
|
|
||||||
|
if (OutputPath == InputPath):
|
||||||
|
RecurseDir = True
|
||||||
|
FileHistoryPath = f"{InputPath}/{Parse(ConfNames["FileHistoryName"], Parent = os.path.basename(InputPath))}.toml"
|
||||||
|
|
||||||
|
if not os.path.exists(FileHistoryPath):
|
||||||
|
with open(FileHistoryPath, "w", encoding = "utf-8") as HistoryFile:
|
||||||
|
toml.dump({"Title": f"{os.path.basename(InputPath)} History", "History": [] }, HistoryFile)
|
||||||
|
|
||||||
for FileName in os.listdir(InputPath):
|
for FileName in os.listdir(InputPath):
|
||||||
FilePath = os.path.join(InputPath, FileName)
|
FilePath = f"{InputPath}/{FileName}"
|
||||||
|
|
||||||
if os.path.isfile(FilePath):
|
if os.path.isfile(FilePath):
|
||||||
FileName = os.path.basename(FilePath)
|
FileName = os.path.basename(FilePath)
|
||||||
if FileName.startswith(".") and Conf["DotFiles"] == 0:
|
if FileName.startswith(".") and Conf["DotFiles"] == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if RecurseDir:
|
||||||
|
HistoryFile = toml.load(FileHistoryPath)
|
||||||
|
|
||||||
|
if (Parse(FileName, Parent = os.path.basename(InputPath)) in HistoryFile["History"]):
|
||||||
|
continue
|
||||||
|
|
||||||
Sort(FilePath)
|
Sort(FilePath)
|
||||||
|
|
||||||
time.sleep(Conf.get("CheckInput", 10))
|
time.sleep(Conf.get("CheckInput", 10))
|
||||||
|
|||||||
Reference in new issue
Block a user