Skip to content

Instantly share code, notes, and snippets.

@thewellington
Created August 15, 2014 15:48
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 thewellington/db4b1561bca0d67e65ce to your computer and use it in GitHub Desktop.
Save thewellington/db4b1561bca0d67e65ce to your computer and use it in GitHub Desktop.
This script will recursively delete the .DS_Store file generated by Macintosh computers. It takes a single argument, the path of the directory where you wish to begin the recursive deletion. Works on both Linux and Macs (with GNU find or BSD find)
#!/usr/bin/env bash
#
# This script will recursively delete the .DS_Store file generated by Macintosh computers.
# It takes a single argument, the path of the directory where you wish to begin the recursive deletion.
#
# works on both Linux and Macs (with GNU find or BSD find)
#
# EXAMPLE:
# dsstore_cleanup.sh /path/to/directory/
#
# v 0.1 2014-08-15 by bill@wellingtonnet.net
if [ "$1" != "" ]; then
WORKING_PATH="${1%/}"
else
WORKING_PATH='.'
fi
case $( uname -s ) in
Linux) find "${WORKING_PATH}" -name .DS_Store -printf \"%p\"\ \ | xargs rm;;
Darwin) find "${WORKING_PATH}" "-name" ".DS_Store" -exec rm {} \;;;
*) echo "Sorry, this script is not setup for this OS";;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment