Last active
August 29, 2015 14:02
-
-
Save ccraig/1f81576e0f6976357c95 to your computer and use it in GitHub Desktop.
Recursively removes all .DS_Store files from a given directory. Usage: ds_destroyer [-n] directory. Shamelessly stole the -n flag from rsync
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 | |
dry_run=$1 | |
dir=$2 | |
if [ $# == 1 ]; then | |
dir=$1 | |
if [ ! -d $dry_run ]; then | |
echo "Directory '$dir' does not exist" | |
echo "Usage: ds_destroyer [-n] <directory>" | |
exit 1 | |
fi | |
else | |
if [ "$dry_run" != "-n" ] || [ ! -d $dir ]; then | |
if [ ! -d $dir ]; then | |
echo "Directory '$dir' does not exist" | |
fi | |
echo "Usage: ds_destroyer [-n] <directory>" | |
exit 1 | |
fi | |
fi | |
for ds in `find $dir -name '.DS_Store'`; do | |
if [ "$dry_run" != "-n" ]; then | |
echo "Removing: $ds" | |
rm $ds | |
else | |
echo "Would Remove: $ds" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment