[Dovecot] OT: Counting emails in IMAP folders
Steffen Kaiser
skdovecot at smail.inf.fh-brs.de
Mon Nov 17 09:43:51 EET 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, 17 Nov 2008, Nigel Allen wrote:
> We can do it over imap or on the server (FC6). They are using maildir.
With IMAP use the "EXISTS" info:
1 LOGIN user pwd
2 SELECT "Customers.Fred Jones"
* 1 EXISTS
..
3 SELECT "Customers.Fred Firestone"
* 6 EXISTS
...
n LOGOUT
On filesystem count the number of regular files in cur and new subdirs:
cd /path-to-maildir
for dir in .Customers.*; do
let cnt="$(ls "$dir/new"|wc -l) + $(ls "$dir/cur"|wc -l)"
# or: let cnt=$(find "$dir"/{cur,new} -type f|wc -l)
# compare cnt with last count
# you could store the value into "$dir/lastcnt"
done
Bye,
- --
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFJISC5VJMDrex4hCIRAiW+AJ9jzfuqHp0jeM0MGvQjZMWk+lNangCfSYR7
5NXZ4O45BKzDn62dRPLFpq8=
=TK6c
-----END PGP SIGNATURE-----
More information about the dovecot
mailing list