Skip to content

Instantly share code, notes, and snippets.

@snappytux
Created May 15, 2025 04:06
Show Gist options
  • Save snappytux/980541ce5c62ba36497566e47a62eb50 to your computer and use it in GitHub Desktop.
Save snappytux/980541ce5c62ba36497566e47a62eb50 to your computer and use it in GitHub Desktop.
find and delete all .DS_Store files in a directory and its subdirectories
#!/bin/bash
# Script to delete all .DS_Store files in the current directory and subdirectories
echo "Starting to search for and delete .DS_Store files..."
# Find and count all .DS_Store files
found_files=$(find . -type f -name ".DS_Store")
count=$(echo "$found_files" | grep -c "^")
if [ $count -eq 0 ]; then
echo "No .DS_Store files found."
exit 0
fi
echo "Found $count .DS_Store files."
echo "Deleting files..."
# Find and delete all .DS_Store files
find . -type f -name ".DS_Store" -delete
echo "Successfully deleted $count .DS_Store files."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment