Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-25 Thread Chris Green
On Tue, Jan 25, 2022 at 12:02:34PM +0100, Marcus C. Gottwald wrote:
> 
> Chris Green wrote (Sun 2022-Jan-23 10:46:33 +):
> 
> > Both hierarchies will be on the same computer so it isn't an IMAP
> > synchronisation tool I'm looking for.  These are just directory trees
> > full of maildir mailboxes.
> 
> How about copying files on disk?
> 
> You could use "find" and/or "grep" to find the messages (= files);
> use hardlinks if you're sure that no message will be modified; use
> reflinks if the filesystem supports them; or simply copy from your
> current area to the archive again and again, if it's not too much
> data; use "fdupes" to remove duplicates (= identical content in
> differently named files) if there's a chance for duplicates being
> created.
> 
That's a point!

If I simply use rsync to copy my 'current' maildir hierarchy to the
'archive' hierarchy then only the newer files get copied, all the
older ones will already be there.  It might be worth running fdupes on
the archive occasionally but I don't think duplicates would be a big
problem, the occasional one won't matter anyway.

All I need to do then is delete files older than whatever date I
decide to 'archive' and the job's done!

-- 
Chris Green


Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-25 Thread Marcus C. Gottwald


Chris Green wrote (Sun 2022-Jan-23 10:46:33 +):

> Both hierarchies will be on the same computer so it isn't an IMAP
> synchronisation tool I'm looking for.  These are just directory trees
> full of maildir mailboxes.

How about copying files on disk?

You could use "find" and/or "grep" to find the messages (= files);
use hardlinks if you're sure that no message will be modified; use
reflinks if the filesystem supports them; or simply copy from your
current area to the archive again and again, if it's not too much
data; use "fdupes" to remove duplicates (= identical content in
differently named files) if there's a chance for duplicates being
created.

Cheers, Marcus

-- 
   Marcus C. Gottwald  ยทยท  @mcg:cheers.de



Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-25 Thread Cameron Simpson
On 24Jan2022 08:55, Chris Green  wrote:
>On Mon, Jan 24, 2022 at 10:24:41AM +1100, Cameron Simpson wrote:
>> On 23Jan2022 10:46, Chris Green  wrote:
>> >This is a bit off topic for mutt specifically but it's about doing
>> >things to the mail I read using mutt, so it's not *very* OT.  :-)
>>
>> Had you considered a shell script which invokes mutt with -e to copy
>> messages tagged by criteria from a mail folder to your archive folder?
>>
>That's a good idea, thank you.  I have done things like this before
>(i.e. an mbox to maildir script using mutt), not very fast but who
>cares, it can take some hours for all I care.
>
>I think it may need a separate process to de-duplicate the destination
>but that's OK.

If you're merging from several folders to the archive, I expect so. Mutt 
can do that, BTW. Order by threads, tags duplicates (~=) and delete 
them.

My folder hooks start like this:

folder-hook . 'push 
"~=~T"'

to do that: tag duplicates, delete (conditional on anything being 
tagged), untag tagged messages (~T).

Cheers,
Cameron Simpson 


Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-24 Thread Claus Assmann
I recently wrote something like that but for mailboxes.  It uses
formail etc and requires that each mail has a Message-Id (which
some didn't have...).
Look into the -D and -s options of formail, maybe it works for
maildirs too?


Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-24 Thread Chris Green
On Mon, Jan 24, 2022 at 10:34:39AM +1100, raf wrote:
> On Mon, Jan 24, 2022 at 10:24:41AM +1100, Cameron Simpson  
> wrote:
> 
> > On 23Jan2022 10:46, Chris Green  wrote:
> > >This is a bit off topic for mutt specifically but it's about doing
> > >things to the mail I read using mutt, so it's not *very* OT.  :-)
> > 
> > Had you considered a shell script which invokes mutt with -e to copy 
> > messages tagged by criteria from a mail folder to your archive folder?
> > 
> > Cheers,
> > Cameron Simpson 
> 
> That sounds clever and simple. I was thinking of
> https://github.com/lefcha/imapfilter but you'd need to
> know lua, and have imap access (rather than just file
> system access) to both sets of messages.
> 
Yes, there's quite a few similar imap/maildir utilities but they mostly
seem aimed at pulling stuff off a [remote] IMAP server to an archive
locally.  I've looked at several in my search.

-- 
Chris Green


Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-24 Thread Chris Green
On Mon, Jan 24, 2022 at 10:24:41AM +1100, Cameron Simpson wrote:
> On 23Jan2022 10:46, Chris Green  wrote:
> >This is a bit off topic for mutt specifically but it's about doing
> >things to the mail I read using mutt, so it's not *very* OT.  :-)
> 
> Had you considered a shell script which invokes mutt with -e to copy 
> messages tagged by criteria from a mail folder to your archive folder?
> 
That's a good idea, thank you.  I have done things like this before
(i.e. an mbox to maildir script using mutt), not very fast but who
cares, it can take some hours for all I care.

I think it may need a separate process to de-duplicate the destination
but that's OK.

-- 
Chris Green


Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-23 Thread raf
On Mon, Jan 24, 2022 at 10:24:41AM +1100, Cameron Simpson  
wrote:

> On 23Jan2022 10:46, Chris Green  wrote:
> >This is a bit off topic for mutt specifically but it's about doing
> >things to the mail I read using mutt, so it's not *very* OT.  :-)
> 
> Had you considered a shell script which invokes mutt with -e to copy 
> messages tagged by criteria from a mail folder to your archive folder?
> 
> Cheers,
> Cameron Simpson 

That sounds clever and simple. I was thinking of
https://github.com/lefcha/imapfilter but you'd need to
know lua, and have imap access (rather than just file
system access) to both sets of messages.

cheers,
raf



Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-23 Thread Cameron Simpson
On 23Jan2022 10:46, Chris Green  wrote:
>This is a bit off topic for mutt specifically but it's about doing
>things to the mail I read using mutt, so it's not *very* OT.  :-)

Had you considered a shell script which invokes mutt with -e to copy 
messages tagged by criteria from a mail folder to your archive folder?

Cheers,
Cameron Simpson 


Re: Slightly OT: I'm looking for a tool to merge maildirs

2022-01-23 Thread Jean Louis
* Chris Green  [2022-01-23 13:59]:
> This is a bit off topic for mutt specifically but it's about doing
> things to the mail I read using mutt, so it's not *very* OT.  :-)
> 
> I'm looking for a way to keep an archive (as in a maildir hierarchy)
> of *all* my mail into which I can merge my current (S[aved] in to
> using mutt) maildir hierarchy.
> 
> This isn't just a straight copy of everything as there will be some
> (quite a lot of) overlap.  I.e. I will keep mail dating back to (say)
> 2010 in my current, seen directly by mutt, mail hierarchy and I will
> want to merge this into the archive at (say) monthly intervals so
> there will be some years of E-Mails that are in both hierarchies.
> 
> Both hierarchies will be on the same computer so it isn't an IMAP
> synchronisation tool I'm looking for.  These are just directory trees
> full of maildir mailboxes.
> 
> I will, if necessary, write it myself, probably in Python but I don't
> want to reinvent the wheel if I don't have to.

Recommended tool is "sieve" form and sieve language to sort emails:

GNU Mailutils
https://mailutils.org/

In my particular example I am using the command line "sieve" to save mbox

function save-maildir-by-to () {
sieve -f /home/admin/Maildir/Sent.mbox.2021 
"/home/data1/protected/Programming/System 
Administration/sieve/save-by-to.sieve" && echo Sieve DONE.
}

And
/home/data1/protected/Programming/System Administration/sieve/save-by-to.sieve
being following:

require [ "fileinto", "variables" ];
if address :matches [ "to" ] "*" {
  set "recipient" :lower "${1}";
  fileinto "~/Maildir/${recipient}";
}

You may look into the sieve language and sort emails by other
means. You also need to give the default maildir option to sieve. It
can convert from one format to other. Thus you could sort it by date
or anyhow.

What I recommend is that every conversation with per...@example.com is
saved in ~/Maldir/per...@example.com

Then by single click on the email from per...@example.com I am
launching new instance of mutt to review all previous emails related
to this person. Isn't that handy?

Then by clicking q, I exit the new instance of mutt and come back to
original email.

Then I have database backed CRM system, so if I wish to find any
person, that person may have assigned multiple email addresses and I
can then review them with single click or by choice within mutt. Mutt
is then opening "mutt -f ~/Maildir/someem...@example.com" in new
terminal, but it can work in console as well.

To understand sieve language, look in the manual of GNU Mailutils.




-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/


Slightly OT: I'm looking for a tool to merge maildirs

2022-01-23 Thread Chris Green
This is a bit off topic for mutt specifically but it's about doing
things to the mail I read using mutt, so it's not *very* OT.  :-)

I'm looking for a way to keep an archive (as in a maildir hierarchy)
of *all* my mail into which I can merge my current (S[aved] in to
using mutt) maildir hierarchy.

This isn't just a straight copy of everything as there will be some
(quite a lot of) overlap.  I.e. I will keep mail dating back to (say)
2010 in my current, seen directly by mutt, mail hierarchy and I will
want to merge this into the archive at (say) monthly intervals so
there will be some years of E-Mails that are in both hierarchies.

Both hierarchies will be on the same computer so it isn't an IMAP
synchronisation tool I'm looking for.  These are just directory trees
full of maildir mailboxes.

I will, if necessary, write it myself, probably in Python but I don't
want to reinvent the wheel if I don't have to.

-- 
Chris Green