### vim:ft=zsh:foldmethod=marker
###
### count mail (new mail that is)

local md=${MAILDIR:-${HOME}/Mail}
local c  ; integer c
local bc ; integer bc
local i
local b

(( c=0 ))
for i in ${md}/*(/N) ; do
    (( bc=0 ))
    for b in ${i}/new/*(.N) ; do
        (( c++  ))
        (( bc++ ))
    done
    if (( bc > 0 )) ; then
        (( bc == 1 )) && printf "%7d new Mail  in %s\n" $((bc)) ${i:t}
        (( bc >  1 )) && printf "%7d new Mails in %s\n" $((bc)) ${i:t}
    fi
done
(( c >= 1 )) && printf "--------------------------------------------------\n"
(( c >  1 )) && printf "%7d new Mails in total.\n" $((c))
(( c == 1 )) && printf "%7d new Mail in total.\n" $((c))
(( c == 0 )) && printf "%7s new Mail.\n" "No"
return 0