Created
June 6, 2014 09:17
-
-
Save brandonpittman/f4cfeef3cccf530ac232 to your computer and use it in GitHub Desktop.
recursively delete .DS_Store files
This file contains 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 | |
# This script removes all annoying .DS_Store' | |
s recursively from you Mac | |
# The first argument is the starting directory | |
# from: https://coderwall.com/p/oxxwca | |
search_folder () { | |
dir="$1" | |
if [ -d "$dir" ];then | |
file='' | |
for file in $(ls -a "$dir");do | |
#echo $dir / $file | |
if [ "$file" != "." ] && [ "$file" != ".." ];then | |
if [ -d "$dir/$file" ];then | |
search_folder "$dir/$file" | |
elif [ "$file" == ".DS_Store" ];then | |
echo "$dir/$file" | |
mkdir -p "$HOME/.Trash/DS_Store/$dir" | |
mv "$dir/$file" "$HOME/.Trash/DS_Store/$dir/$file" | |
fi | |
fi | |
dir="$1" | |
done | |
fi | |
} | |
dir=${1/~/$HOME} | |
if [ ! -d "$dir" ];then | |
dir="$PWD/$dir" | |
fi | |
search_folder $dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment