[Dovecot] Bash script to mark all mail read in Maildir + Dovecot
Andrew Oakley
andrew at aoakley.com
Fri Jan 9 18:26:49 EET 2009
Hi, I'm writing a script to mark all new mail read, including all mail
in folders, for my system which uses Maildir and Dovecot.
The reason for this script is that I use Google Mail at work, which
forwards to my SMTP/IMAP system at home. When I've finished my last
check of GMail at work, I want to be able to quickly mark all mail as
read at home too.
Basically this script moves everything from all /new/ directories to
/cur/ directories and appends :2,S ("Seen" info status) to the
filename.
It seems to work, but I'm relatively new to IMAP and Maildir. Can
anyone spot any potential problems? Thanks.
----cut here---
#!/bin/bash
# markallread by Andrew Oakley www.aoakley.com Public Domain 2009-01-09
# A script to mark all MAILDIR mail as read, including folders
# Assumes Dovecot folder naming dot prefix eg. ~/.maildir/.foldername
# Loop through ~/.maildir/.foldername/new/ directories
# This also does the ~/.maildir Inbox since it matches ~/.maildir/./new/
for i in `ls -1 ~/.maildir/.*/new/*`
do
# Replace /new/ with /cur/
# Also add status "seen" to message by appending :2,S to filename
# as per http://cr.yp.to/proto/maildir.html
mv $i `echo $i | sed -r "s/^(.*)\/new\/(.*)$/\1\/cur\/\2:2,S/"`
done
----end cut here---
--
Andrew Oakley andrew at aoakley.com
More information about the dovecot
mailing list