Skip to content

Instantly share code, notes, and snippets.

@rutger1140
Created March 14, 2012 11:03
Show Gist options
  • Save rutger1140/2035793 to your computer and use it in GitHub Desktop.
Save rutger1140/2035793 to your computer and use it in GitHub Desktop.
Clean up DS store files on OSX
#!/bin/sh
# bash script to clean (delete) Finder .DS_Store, .Trashes and ._resources
# Use cleandsstores.sh
# juanfc 2010-03-06
if [ $# != 1 ]
then
echo "ERROR: use\n\t`basename $0` dirtoclean"
exit 1
fi
res=`find "$@" \( -name ".DS_Store" -or -name ".Trashes" -or -name "._*" \) -print`
if [[ -z $res ]]; then
echo "nothing to delete"
exit 0
else
echo "Going to delete:"
echo $res
fi
read -p "Ok (yYsS1)?" ok
case $ok in
[yYsS1] )
find "$@" \( -name ".DS_Store" -or -name ".Trashes" -or -name "._*" \) -exec rm -rf "{}" \; -prune ;;
* )
echo "aborted."
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment