On Thu, Nov 03, 2005 at 03:28:23PM +0000, MJ Ray wrote:
Chris Green chris@areti.co.uk
This is (distantly) related to my previous question, they're both results of my migration from mbox to maildir. I'm doing that so I can rsync my mail folder hierarchy from the system where I actually read my mail to my home system without losing old mails.
Can't mailsync do that without maildir? Maildir always looked to me like a third-choice format for normal users, after mbox and mh.
Can it? There aren't IMAP servers at both ends, isn't mailsync an IMAP tool?
Give mail on systems A and B, where B is the backup system I want to:-
Copy any message in B's ~/Mail hierarchy to the same place in A's ~/Mail hierarchy leaving all existing mail on A.
I can thus delete old mail on B but have it archived on A.
With mbox this is rather difficult, with maildir and rsync it's trivial.
This involves finding any directory that has empty cur, tmp, and new subdirectories and deleting it. I can see all sorts of horribly clumsy ways of doing it but not any really neat way.
Any quick solutions anyone?
Quickest to my mind is the fugly
find $(find $(find $HOME/Maildir/ -name cur -type d -empty -printf '%h\n') \ -maxdepth 1 -name tmp -type d -empty -printf '%h\n') \ -maxdepth 1 -type d -name new -empty -printf '%h\n' \ | while read dir ; do rmdir -v "$dir/cur" "$dir/new" "$dir/tmp" "$dir/" done
Yes, I'd got to the stage of thinking about multiple finds, maybe it's the only way.
which feeds the cur find paths to a limited tmp find and again to a limited new find, then tries to rmdir anything still found. You need to be sure you don't have newlines or other funnies in names.
It's a lot more complicated than the equivalent for mboxes (find $HOME/mail/ -type f -size 0 -exec rm -v '{}' ';')
I don't need to do it at all with mbox as mutt will remove empty mailboxes automatically if you tell it to.