Skip to content

Instantly share code, notes, and snippets.

@emotality
Created July 7, 2015 21:15
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 emotality/a3a5b7fcc62e5075a105 to your computer and use it in GitHub Desktop.
Save emotality/a3a5b7fcc62e5075a105 to your computer and use it in GitHub Desktop.
Delete all .DS_Store files in OSX.
#!/bin/bash
#### Created by Jean-Pierre Fourie
### https://github.com/emotality
## delete_ds_store.sh
#
clear
echo " "
echo " ########################################################## "
echo " #################### DELETE .DS_STORE #################### "
echo " ########################################################## "
echo " "
echo " ** Note: Make sure the script is in the upper directory where you want to"
echo " delete the .DS_Store files in all the lower directories." **
echo " ** Note: Close all Finder windows. **"
echo " "
CURRENT_PATH="`dirname \"$0\"`"
cd "$CURRENT_PATH"
var=$(pwd)
echo " The current working directory is: '$var'"
echo " "
read -p " Delete all .DS_Store files in this and all sub-directories? [y/n]: " answer
case "$answer" in
y|Y ) find . -name ".DS_Store" -print0 | xargs -0 rm -rf; echo " All .DS_Store files has been deleted \n";;
n|N ) echo " Then what are we doing here? \n";;
* ) echo " Invalid option.. Exiting. \n";;
esac
killall Finder
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment