#!/bin/bash # Initialize variables auto_confirm=false # Parse arguments for the folder path and the -y option while [[ "$#" -gt 0 ]]; do case "$1" in -y) auto_confirm=true ;; *) folder_path="$1" ;; esac shift done # If no folder path is provided, exit with an error if [ -z "$folder_path" ]; then echo "No folder path provided. Exiting." exit 1 fi # Check if the provided path is valid if [ ! -d "$folder_path" ]; then echo "Invalid folder path. Please provide a valid directory." exit 1 fi # Find all .Trash-1000 directories within the provided path echo "Searching for .Trash-1000 folders in $folder_path..." trash_folders=$(find "$folder_path" -type d -name ".Trash-1000") if [ -z "$trash_folders" ]; then echo "No .Trash-1000 folders found." else echo "Found the following .Trash-1000 folders:" echo "$trash_folders" echo # If the -y option is not provided, automatically confirm deletion if [ "$auto_confirm" = false ]; then echo "Deleting all .Trash-1000 folders without confirmation..." fi # Loop through each found folder and delete it while IFS= read -r folder; do echo "Deleting folder: $folder" rm -rf "$folder" echo "Deleted $folder" done <<< "$trash_folders" echo "All .Trash-1000 folders have been deleted." fi