mirror of
https://git.srhtnin.garden/sarah/SaraSortd.git
synced 2026-10-13 18:38:11 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70a36d8b96 | ||
|
|
19ceec218f | ||
|
|
2cc72b1730 | ||
|
|
2bf4457981 | ||
|
|
5c39166a66 | ||
|
|
6a6e7dd494 | ||
|
|
a83b2e3c94 | ||
|
|
9be5938a87 | ||
|
|
4e00617e09 | ||
|
|
c5612654f8 | ||
|
|
324d06d6b4 | ||
|
|
b5afad3895 | ||
|
|
a314614055 | ||
|
|
3aa28f76cf | ||
|
|
89f4e59041 | ||
|
|
dc60a9828e | ||
|
|
4901d346f2 | ||
|
|
b04c3426a7 | ||
|
|
15ced89964 | ||
|
|
475eda8dd2 | ||
|
|
e9974f90ee |
No files matched your search
+3
-3
@@ -1,8 +1,8 @@
|
||||
Title = "SaraSortd Config"
|
||||
Version = "6.0"
|
||||
Version = "7.0"
|
||||
SafeMode = 1
|
||||
SilentMode = 0
|
||||
CheckInput = 5
|
||||
SortTimer = 1
|
||||
DotFiles = 0
|
||||
Logging = 1
|
||||
OverwriteDirConf = 0
|
||||
@@ -22,7 +22,7 @@ Second = "[s]"
|
||||
VarCall = "%%"
|
||||
|
||||
[DirectoryPaths]
|
||||
RootDir = "C:/Users/StigOscarAadalen-Aas/OneDrive - Telemark fylkeskommune/Desktop/Testdir"
|
||||
RootDir = "Unset"
|
||||
InputDir = [ "%RootDir%/Input" ]
|
||||
OutputDir = [ "%RootDir%/Output" ]
|
||||
LogDir = "%RootDir%/.Logs"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
Title = "Unset"
|
||||
Version = "6.0"
|
||||
Version = "7.0"
|
||||
ParentDir = "Unset"
|
||||
SortDirs = 0
|
||||
|
||||
|
||||
File renamed without changes.
+2
-1
@@ -1,10 +1,11 @@
|
||||
Title = "Unset"
|
||||
Version = "6.0"
|
||||
Version = "7.0"
|
||||
LastFile = "Unset"
|
||||
ParentDir = "Unset"
|
||||
ValidInputDirs = ["*"]
|
||||
FileLimit = 0
|
||||
DeleteOrg = 1
|
||||
Unzip = []
|
||||
|
||||
[[Files]]
|
||||
Pattern = "*"
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
# SaraSortd
|
||||
(Version = "6.0")
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/SaraSortd.png" width="100%" alt="SaraSortd: a file and directory sorting daemon built with python."/>
|
||||
|
||||
(Version = "7.0")
|
||||
|
||||
A python daemon that can automatically sort your files to your liking without using AI.
|
||||
|
||||
It's made by Sarah, hence the name. :3
|
||||
|
||||
## Usage
|
||||
If the first number in the version goes up, it means that old config files will not work with the new SaraSortd.py.
|
||||
If the second number in the version goes up, something new got added, but your old config files will still work just fine.
|
||||
|
||||
---
|
||||
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/Usage.png" width="100%" alt="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.
|
||||
|
||||
@@ -17,44 +23,48 @@ Example use-cases:
|
||||
|
||||
- Regularly cloning important files into a backup directory.
|
||||
|
||||
## Dependencies
|
||||
---
|
||||
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/Dependencies.png" width="100%" alt="Dependencies"/>
|
||||
|
||||
|
||||
python
|
||||
|
||||
toml: Use ```pip install toml``` to install toml.
|
||||
|
||||
## Versioning
|
||||
---
|
||||
|
||||
If the first number in the version goes up, it means that old config files will not work with the new SaraSortd.py.
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/Installation.png" width="100%" alt="Installation"/>
|
||||
|
||||
If the second number in the version goes up, something new got added, but your old config files will still work just fine.
|
||||
|
||||
## Installation
|
||||
Here's an [installation video](https://youtu.be/QkMZVSJ-PLQ?si=Nd20jDyHT7CN6Ztb) on Linux.
|
||||
|
||||
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.
|
||||
1. Install ZIP-file by clicking the green "Code" button on the top right, then clicking "Download Zip".
|
||||
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.
|
||||
3. Edit your config files to your liking. Make sure to edit your paths! (E.G. RootDir = "/home/janedoe/Programs/SaraSortd")
|
||||
4. Navigate to the new SaraSortd directory in your terminal (CMD / PowerShell on Windows).
|
||||
5. Run ```python SaraSortd.py``` to run the program. (This will make new directories for you.)
|
||||
6. Edit your output directories' configs.
|
||||
6. Edit your new output directories' configs.
|
||||
|
||||
## Config explanation
|
||||
---
|
||||
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/ConfigInfo.png" width="100%" alt="Config Info"/>
|
||||
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/GlobalConf.png" width="100%" alt="GlobalConf"/>
|
||||
|
||||
### SaraSortd Config (GlobalConf.toml)
|
||||
|
||||
```
|
||||
Title = "SaraSortd Config" # NOTE: Do not change the title. This is so that the program knows which config file is which.
|
||||
|
||||
Version = "6.0" # Just the version number for the config file.
|
||||
Version = "7.0" # 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.
|
||||
|
||||
SilentMode = 0 # If SaraSortd should write things it does, to the terminal.
|
||||
|
||||
CheckInput = 3 # How many seconds it takes for SaraSortd to check input directories for new files to sort.
|
||||
SortTimer = 3 # How many seconds it takes for SaraSortd to check input directories for new files to sort.
|
||||
|
||||
DotFiles = 0 # If SaraSortd should sort files that begin with ".". This is mainly for linux users, since hidden files always have "." in front of them.
|
||||
|
||||
@@ -138,16 +148,17 @@ Unzipping = "Unzipping: %%." # When a directory gets unzipped.
|
||||
NoPermission = "Error: No permission to %%." # When SaraSortd lacks permission to do something.
|
||||
# %% is the action that the program had no permission to do. E.G. "remove directory /home/bob/exampledir".
|
||||
```
|
||||
---
|
||||
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/OutputDirConf.png" width="100%" alt="OutputDirConf"/>
|
||||
|
||||
### Output Directory Config (OutputDirConf.toml)
|
||||
|
||||
The output directory config references the SaraSortd config (GlobalConf.toml). This means that you can, for example, use the character assigned to "NextNum" in GlobalConf.toml in this config (OutputDirConf.toml). This applies to all Variables in the SaraSortd config (GlobalConf.toml).
|
||||
|
||||
```
|
||||
Title = "Unset" # NOTE: Do not change the title. This is so that the program knows which config file is which.
|
||||
|
||||
Version = "6.0" # The version number of the config.
|
||||
Version = "7.0" # 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.
|
||||
|
||||
@@ -159,6 +170,9 @@ 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 = [] # What type of files this output directory should try to unzip. E.G:
|
||||
# Unzip = ["zip", "tar.gz"] would unzip .zip files and .tar files. This pairs insanely well with input directories' config's "SortDirs" parameter.
|
||||
|
||||
[[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]]
|
||||
@@ -190,16 +204,19 @@ CaseSensitive = 0 # Whether this "Pattern" is case-sensitive or not. 1 is yes, 0
|
||||
Overwrite = 1 # Whether this specific file type can be overwritten by others of the same type. 0 is no, 1 is yes.
|
||||
```
|
||||
|
||||
### Input Directory Config (InputDirConf.toml)
|
||||
---
|
||||
|
||||
<img align="center" src="https://github.com/SRHTNIN/RepoAssets/blob/main/SaraSortd/Banners/InputDirConf.png" width="100%" alt="InputDirConf"/>
|
||||
|
||||
|
||||
```
|
||||
Title = "Unset" # NOTE: Do not change the title. This is so that the program knows which config file is which.
|
||||
|
||||
Version = "6.0"
|
||||
Version = "7.0"
|
||||
|
||||
ParentDir = "Unset" # The name of this directory. It gets automatically updated when this config gets copied to an output directory.
|
||||
|
||||
SortDirs = 0
|
||||
SortDirs = 0 # If the input directory should be allowed to sort directories within it. Automatically uses .zip to move directories.
|
||||
|
||||
[[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.
|
||||
|
||||
@@ -207,3 +224,5 @@ Pattern = "*" # A pattern used to decide if a file should be sorted or not. * is
|
||||
|
||||
CaseSensitive = 0 # Whether Pattern is case-sensitive or not. If CaseSensitive = 1 and your pattern is "*.PNG", then a file named "example.png" won't be sorted.
|
||||
```
|
||||
|
||||
---
|
||||
+27
-3
@@ -6,7 +6,7 @@ import shutil
|
||||
import time
|
||||
import toml
|
||||
|
||||
# Version = "6.0"
|
||||
# Version = "7.0"
|
||||
|
||||
ConfPath = "./GlobalConf.toml"
|
||||
|
||||
@@ -500,6 +500,30 @@ def Main():
|
||||
|
||||
for Output in ConfDirs["OutputDir"]:
|
||||
OutputPath = Parse(Output)
|
||||
OutDirConfPath = f"{OutputPath}/{Parse(ConfNames["OutDirConfName"], Parent = os.path.basename(OutputPath))}.toml"
|
||||
|
||||
if len(GetConf("Unzip", OutDirConfPath)) >= 1:
|
||||
ZipTypes = GetConf("Unzip", OutDirConfPath)
|
||||
for OutputFile in os.listdir(OutputPath):
|
||||
if OutputFile.startswith("."):
|
||||
continue
|
||||
|
||||
for ZipType in ZipTypes:
|
||||
print(ZipType)
|
||||
if (OutputFile.lower()).endswith((ZipType).lower()):
|
||||
shutil.unpack_archive(f"{OutputPath}/{OutputFile}", OutputPath)
|
||||
TextOutput = Parse(String = ConfLog["Unzipping"], VarCall = f"{OutputPath}/{OutputFile}")
|
||||
LogWrite(TextOutput)
|
||||
Speak(TextOutput)
|
||||
|
||||
try:
|
||||
os.remove(f"{OutputPath}/{OutputFile}")
|
||||
|
||||
except PermissionError:
|
||||
TextOutput = Parse(String = ConfLog["NoPermission"], VarCall = f"remove {OutputPath}/{OutputFile}")
|
||||
LogWrite(TextOutput)
|
||||
Speak(TextOutput)
|
||||
continue
|
||||
|
||||
if (OutputPath == InputPath):
|
||||
RecurseDir = True
|
||||
@@ -537,7 +561,7 @@ def Main():
|
||||
shutil.make_archive(FilePath, "zip", FilePath)
|
||||
|
||||
try:
|
||||
os.rmdir(FilePath)
|
||||
shutil.rmtree(FilePath, ignore_errors=True)
|
||||
|
||||
except PermissionError:
|
||||
TextOutput = Parse(String = ConfLog["NoPermission"], VarCall = f"remove directory {InputPath}/{FileName}")
|
||||
@@ -555,7 +579,7 @@ def Main():
|
||||
|
||||
Sort(FilePath)
|
||||
|
||||
time.sleep(Conf.get("CheckInput", 10))
|
||||
time.sleep(Conf.get("SortTimer", 10))
|
||||
|
||||
except KeyboardInterrupt:
|
||||
TextOutput = GetConf("Stop", ConfPath)
|
||||
|
||||
Reference in new issue
Block a user