[Dovecot] Bash script to mark all mail read in Maildir + Dovecot
Steve
steeeeeveee at gmx.net
Fri Jan 9 18:52:21 EET 2009
-------- Original-Nachricht --------
> Datum: Fri, 9 Jan 2009 16:26:49 +0000
> Von: "Andrew Oakley" <andrew at aoakley.com>
> An: dovecot at dovecot.org
> Betreff: [Dovecot] Bash script to mark all mail read in Maildir + Dovecot
> 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.
>
I spot a issue with folders having a space in them. Then your script would not work.
> ----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---
>
Out of my head without testing, I would do it that way:
----cut here---
#!/bin/bash
find ~/.maildir/ -type d -mindepth 2 -maxdepth 2 -name "new" | while read foo
do
cd "${foo}" && {
for bar in *
do
mv -iv ${bar} ../cur/${bar}:2,S
done
}
done
----end cut here---
> --
> Andrew Oakley andrew at aoakley.com
>
Steve
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
More information about the dovecot
mailing list