Skip to content

Instantly share code, notes, and snippets.

@solarkraft
Last active December 22, 2022 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solarkraft/245caf3f3940a917126919e08a6fcefe to your computer and use it in GitHub Desktop.
Save solarkraft/245caf3f3940a917126919e08a6fcefe to your computer and use it in GitHub Desktop.
Continually delete meta-files Finder keeps creating on external drives
#!/usr/bin/env bash
path=$1
check() {
file=$1
echo "Checking $file"
# Anything matching /._*
if [[ $file =~ \/\._. ]] || [[ $file =~ \/\.DS_Store ]]; then
echo "Shut up $file"
rm "$file"
fi
}
find $path |
while read file; do
check "$file"
done
inotifywait --event CLOSE_WRITE --monitor --format %w%f --recursive $path |
while read file; do
check "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment