Created
September 4, 2025 09:40
-
-
Save evenwebb/5e9bed48ae78f535706fe27d1f71af84 to your computer and use it in GitHub Desktop.
This script clears a specified download folder, records how many files and how much total data were deleted, and sends a summary notification via Pushover. It’s useful for keeping download directories clean, freeing up disk space, and staying informed with automatic alerts after each cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Store the directory path in a variable for easy modification | |
| dir_path="/mnt/user/Downloads/" | |
| # Count the number of files and directories in the directory | |
| file_count=$(find "$dir_path" -mindepth 1 | wc -l) | |
| # Get the total size of all files in the directory | |
| total_size=$(du -sh "$dir_path" | awk '{print $1}') | |
| # Delete all files and directories in the directory | |
| rm -rf "$dir_path"/* | |
| # Display a summary of the deleted files | |
| summary="Deleted $file_count files in torrent download folder, total size: $total_size" | |
| echo "$summary" | |
| # Send the summary in a Pushover notification | |
| user_key="11111111111111111111111111111111" | |
| app_token="0000000000000000000000000000000" | |
| title="Torrent Downloads Cleared" | |
| priority="1" | |
| url="" | |
| url_title="" | |
| timestamp="$(date +%s)" | |
| curl -s \ | |
| --form-string "token=$app_token" \ | |
| --form-string "user=$user_key" \ | |
| --form-string "title=$title" \ | |
| --form-string "priority=$priority" \ | |
| --form-string "message=$summary" \ | |
| --form-string "url=$url" \ | |
| --form-string "url_title=$url_title" \ | |
| "https://api.pushover.net/1/messages.json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment