diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a60b85 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/GlobalConf.toml b/GlobalConf.toml index 925d069..f8f3815 100644 --- a/GlobalConf.toml +++ b/GlobalConf.toml @@ -1,5 +1,5 @@ Title = "SaraSortd Config" -Version = "7.5" +Version = "7.6" SafeMode = 1 SilentMode = 0 SortTimer = 1 diff --git a/InputDirConf.toml b/InputDirConf.toml index 6652ba0..b8d3aa5 100644 --- a/InputDirConf.toml +++ b/InputDirConf.toml @@ -1,5 +1,5 @@ Title = "Unset" -Version = "7.5" +Version = "7.6" ParentDir = "Unset" SortDirs = 0 diff --git a/OutputDirConf.toml b/OutputDirConf.toml index 9c1692a..d948930 100644 --- a/OutputDirConf.toml +++ b/OutputDirConf.toml @@ -1,5 +1,5 @@ Title = "Unset" -Version = "7.5" +Version = "7.6" LastFile = "Unset" ParentDir = "Unset" ValidInputDirs = ["*"] diff --git a/README.md b/README.md index 758253b..58daf92 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ SaraSortd: a file and directory sorting daemon built with python. -(Version = "7.5") +(Version = "7.6") It's made by Sarah, hence the name. :3 @@ -44,7 +44,7 @@ Here's a step-by-step tutorial (in case you don't want to watch the video). 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. 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). +4. Navigate to the new SaraSortd directory in your terminal (CMD / PowerShell on Windows, Terminal on macOS). 5. Run ```python SaraSortd.py``` to run the program. (This will make new directories for you.) 6. Edit your new output directories' configs. @@ -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 = "7.5" # Just the version number for the config file. +Version = "7.6" # 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. @@ -66,7 +66,9 @@ SilentMode = 0 # If SaraSortd should write things it does, to the terminal. 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. +DotFiles = 0 # If SaraSortd should sort files that begin with ".". This is mainly for Linux and macOS users, since hidden files always have "." in front of them. +# Files the system makes in every folder you look at are never sorted, whatever DotFiles says (since 7.6): .DS_Store (macOS' Finder), Thumbs.db and desktop.ini (Windows' Explorer). +# SaraSortd's own files in an input folder (its config and history) are never sorted either, also with DotFiles = 1 (since 7.6). # Files that are still downloading are never sorted or even checked (since 7.4): anything ending in .part (Firefox), .crdownload (Chrome and other Chromium browsers) or .download (Safari), and a file next to its own unfinished download (like the empty "video.mp4" Firefox makes beside "video.mp4.part"). They're sorted as usual once the download finishes. Logging = 1 # If SaraSortd's logging system should be active. If this is 0, nothing will be logged into files. @@ -170,7 +172,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 = "7.5" # The version number of the config. +Version = "7.6" # 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. @@ -226,7 +228,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 = "7.5" +Version = "7.6" 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 81a1429..a7a5894 100644 --- a/SaraSortd.py +++ b/SaraSortd.py @@ -6,7 +6,7 @@ import shutil import time import toml -# Version = "7.5" +# Version = "7.6" ConfPath = "./GlobalConf.toml" @@ -403,6 +403,15 @@ def FileInputValid(File, FilePath, ParentName): PartialDownloadSuffixes = (".part", ".crdownload", ".download") +# Files the system makes in every folder you look at (since 7.6): macOS' Finder writes .DS_Store, +# Windows' Explorer Thumbs.db and desktop.ini. Never sorted, whatever DotFiles says. +SystemFileNames = (".ds_store", "thumbs.db", "desktop.ini") + + +def IsSystemFile(FilePath): + return os.path.basename(FilePath).lower() in SystemFileNames + + def IsPartialDownload(FilePath): if os.path.basename(FilePath).lower().endswith(PartialDownloadSuffixes): return True @@ -679,9 +688,12 @@ def Main(): with open(FileHistoryPath, "w", encoding = "utf-8") as HistoryFile: toml.dump({"Title": f"{os.path.basename(InputPath)} History", "History": [] }, HistoryFile) + # SaraSortd's own files in the folder (its configs and history) stay put, also with DotFiles = 1 (since 7.6). + OwnFiles = {Slashes(os.path.abspath(Own)) for Own in (DirConfPath(InputPath, "In"), DirConfPath(InputPath, "Out"), HistoryPath(InputPath))} + for FileName in os.listdir(InputPath): FilePath = f"{InputPath}/{FileName}" - if IsPartialDownload(FilePath): + if IsPartialDownload(FilePath) or IsSystemFile(FilePath) or Slashes(os.path.abspath(FilePath)) in OwnFiles: continue if os.path.isdir(FilePath) and InputDirConf.get("SortDirs", 0) == 0: diff --git a/__pycache__/SaraSortd.cpython-314.pyc b/__pycache__/SaraSortd.cpython-314.pyc deleted file mode 100644 index 4cc8b9b..0000000 Binary files a/__pycache__/SaraSortd.cpython-314.pyc and /dev/null differ