With the use of cron jobs this simple Python script will allow you to automatically delete files in your downloads folder. This can be useful when running out of space on your primary drive.
- Clone the repo or download the file with the following command:
wget https://raw.githubusercontent.com/hakrishi/auto-file-deletion/main.py
- Make the file executable:
chmod +x main.py
- Ensure Python3 is installed, downloads can be found here
- Edit the
downloads_folder
VAR with your own downloads folder path - Run the script:
python3 main.py
- Run
crontab -e
- On the very last line add the following:
0 14 * * 0 /path/to/main.py
- Save the file then exit
This will run the script every Sunday at 2PM. Note that you will need to edit the file path for the script.
As always if you find any bugs or issues with the code feel free to open a pull request! 😃