Skip to content

Instantly share code, notes, and snippets.

@timmyreilly
Created September 30, 2025 23:49
Show Gist options
  • Save timmyreilly/de36bf67383243d21ad68056c960e0ac to your computer and use it in GitHub Desktop.
Save timmyreilly/de36bf67383243d21ad68056c960e0ac to your computer and use it in GitHub Desktop.
#!/bin/bash
# Script to remove all Zone.Identifier files from the directory
# These files are Windows metadata files created when downloading from the internet
echo "Searching for Zone.Identifier files in directory..."
# Find and count Zone.Identifier files
ZONE_FILES=$(find . -name "*:Zone.Identifier" -type f)
COUNT=$(echo "$ZONE_FILES" | grep -c "Zone.Identifier" 2>/dev/null || echo "0")
if [ "$COUNT" -eq 0 ]; then
echo "No Zone.Identifier files found."
exit 0
fi
echo "Found $COUNT Zone.Identifier files:"
echo "$ZONE_FILES"
echo
# Prompt for confirmation
read -p "Do you want to remove all these Zone.Identifier files? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Operation cancelled."
exit 0
fi
# Remove the files
echo "Removing Zone.Identifier files..."
find . -name "*:Zone.Identifier" -type f -delete
echo "Done! Removed $COUNT Zone.Identifier files."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment