Last active
October 16, 2024 18:59
-
-
Save jneuendorf/85b3e62645c5f1163baa67baec277c75 to your computer and use it in GitHub Desktop.
clean macOS files from external drive
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 | |
# Path to the external drive | |
EXTERNAL_DRIVE="$1" | |
# Remove .DS_Store, .Trashes, and Icon files | |
find "$EXTERNAL_DRIVE" -name ".DS_Store" -delete | |
find "$EXTERNAL_DRIVE" -name "Icon\r" -delete | |
find "$EXTERNAL_DRIVE" -name ".Trashes" -exec rm -rf {} + | |
# Disable Spotlight indexing | |
sudo mdutil -i off "$EXTERNAL_DRIVE" | |
sudo rm -rf "$EXTERNAL_DRIVE/.Spotlight-V100" | |
# Disable .fseventsd logging | |
sudo touch "$EXTERNAL_DRIVE/.fseventsd/no_log" | |
# Prevent Trash creation (optional, but must be manually emptied) | |
rm -rf "$EXTERNAL_DRIVE/.Trashes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment