aboutsummaryrefslogtreecommitdiff
path: root/local/bin/email-unread
blob: f9e3aa9bee427d5cdaaa2756bb5dad53c944d4fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
EMAIL=~/.mail
IGNORE="(Spam|trash|Important)"

if [ "$1" == "-s" ]; then
	V=n
else
	V=y
fi

for account in $(ls "$EMAIL"); do
	if ! cd $EMAIL/$account; then continue; fi
	COUNT="0"
	COUNT=$(find . -name new -type d -print0 |
	while read -d $'\0' folder; do
		if [ -n "`echo $folder | grep -E $IGNORE`" ]; then
			continue
		fi
		directory=$(echo $folder | sed 's/^\.\///' | sed 's/\/new$//')
		count=$(ls "$folder" | wc -l)
		if [ "$count" -gt "0" ]; then
			if [ $V == 'y' ]; then
				echo "$account/$directory: $count"
			else
				let 'COUNT = COUNT + count'
				echo $COUNT
			fi
		fi
	done | tail -1)
	if [ -n "$COUNT" ]; then
		if [ $V == "n" ]; then
			echo "$account:$COUNT"
		else
			echo $COUNT
		fi
	fi
done