MacBook脚本:删除.DS_Store

1
2
# 禁止在连接的储存中创建 .DS_Store 文件
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
#
# Remove all .DS_Store file
# author: cx
#
# 使用方法:打开终端 -> 执行./rm.DS_Store.sh [可选文件夹路径]
# 例如:./rm.DS_Store.sh
# ./rm.DS_Store.sh ~/Downloads
#

# Terminal work directory
twd=$(pwd)
# Script work directory
swd=$(cd $(dirname $0); pwd)

find ${1:-$swd} \
-path ~/Library -prune -o \
-name ".DS_Store" \
-exec rm {} \; \
-exec echo {} removed \;

# echo All .DS_Store have been removed"
echo "\033[32mAll .DS_Store have been removed\033[0m"