Andrew Oakley
2009-Jan-09 16:26 UTC
[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. ----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
Timo Sirainen
2009-Jan-09 16:51 UTC
[Dovecot] Bash script to mark all mail read in Maildir + Dovecot
On Fri, 2009-01-09 at 16:26 +0000, Andrew Oakley wrote:> 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.Another way would be: printf "1 select inbox\n2 store 1:* +flags \\seen\n" | dovecot --exec-mail imap -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20090109/5e8a8ef4/attachment-0002.bin>
Steve
2009-Jan-09 16:52 UTC
[Dovecot] Bash script to mark all mail read in Maildir + Dovecot
-------- 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
Patrick Ben Koetter
2009-Jan-09 19:31 UTC
[Dovecot] Bash script to mark all mail read in Maildir + Dovecot
* Andrew Oakley <andrew at aoakley.com>:> 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.Why not use imapsync to sync your home mailfolder with Google Mail. imapsync synchronizes message status too. p at rick -- state of mind Agentur f?r Kommunikation, Design und Softwareentwicklung Patrick Koetter Tel: 089 45227227 Echinger Strasse 3 Fax: 089 45227226 85386 Eching Web: http://www.state-of-mind.de Amtsgericht M?nchen Partnerschaftsregister PR 563
Maybe Matching Threads
- Illustrating kernel distribution in wheat ears
- vignette typesetting issue
- Finding a folder at the root level of an unknown drive
- managesieve / sieve - append dot prefix on moving mails into folder
- Samba and "running old wbinfo, pam_winbind or libnss_winbind clients"