Lawn-mower finds all of the files in one or more directories and moves them to another one. At first I thought this would be a silly project, because it takes thought and care to organize a Desktop. Then I realized, I literally never click on Desktop icons. So I made a script that checks for items periodically and moves them to a specified folder. If I really care, I can always go find these items later.
After beginning the project, I realized that windows desktops are generated by several different filepaths. Mine comes from the local user desktop, the public user desktop, and the OneDrive user desktop. For that reason, the config JSON takes a list of files to look in, called SWEEPS.
At this time, DUSTBIN, the variable tracking where the files are placed, only takes one filepath and it should be a directory. If the directory in DUSTBIN doesn't exist, it will be created.
You can place the names of any files to be ignored in the IGNORES array. This should be file names, not file paths. Also, any items which would be overwritten are instead ignored.
After cloning the repository, change the name of example_config.json
to config.json
and open it.
{
"SWEEPS": [
"C:\\Users\\Public\\Desktop"
],
"DUSTBIN": "C:\\Users\\Public\\Dustbin",
"IGNORES": []
}
Place the filepaths to be checked in an array under SWEEPS. On Windows, remember to use double backslash between directories. Place the path to move files to in DUSTBIN. Add the filenames of any files you don't want moved in the IGNORES array.
You need the Python package schedule. This can be installed into a virtual
environment on windows using the provided install.bat
.
Run with python.exe in a terminal to see the working log printed as the script executes.
On Windows, use the lawn-mower.bat
to run in the installed venv with
pythonw.exe. This will maintain the process in the background. You then need to
use taskkill /pid -processId- /f
to kill the process.
While the program is active, it will run about every 2 minutes.
- I want to package the program in an .exe for portability.
- I may expand the logic to organize files, not just move them all in a heap.
- Add modified frequency