ask before deleting
This commit is contained in:
@@ -9,7 +9,7 @@ if [ ! -d "$folder_path" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find and delete all .Trash-1000 directories within the provided path
|
||||
# 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")
|
||||
@@ -21,6 +21,10 @@ else
|
||||
echo "$trash_folders"
|
||||
echo
|
||||
|
||||
# Ask for confirmation before deletion
|
||||
read -p "Do you really want to delete all these folders? (y/n): " confirmation
|
||||
|
||||
if [[ "$confirmation" == "y" || "$confirmation" == "Y" ]]; then
|
||||
# Loop through each found folder and delete it while displaying progress
|
||||
while IFS= read -r folder; do
|
||||
echo "Deleting folder: $folder"
|
||||
@@ -29,4 +33,7 @@ else
|
||||
done <<< "$trash_folders"
|
||||
|
||||
echo "All .Trash-1000 folders have been deleted."
|
||||
else
|
||||
echo "Deletion canceled."
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user