Re: 'all' folder msgs from last 3 weeks; of symlinks?

2022-09-20 Thread Bakul Shah
On Sep 20, 2022, at 8:18 AM, Tom R  wrote:
> 
> I would be ok with symlinks or hardlinks; but symlinks are better since I 
> could
> quickly find which folder the msg first landed in.

You can use a sequence to keep track of which folder a message came
from. Then you just have to run a function like

msg2seq() { grep "\<$1\>" .mh_sequences|sed 's/:.*//'}

to reverse map a msg to the sequence(s) it is part of. One benefit
is MH will maintain them properly as you rmm, sortm old messages etc.




Re: 'all' folder msgs from last 3 weeks; of symlinks?

2022-09-20 Thread Conrad Hughes
Tom> I had mairix installed; and I was doing that -- except that I did not
Tom> have a script to easily update the list of all my folders.

Yep, you need that alright!  I've got it running on cron.

Best,
Conrad



Re: 'all' folder msgs from last 3 weeks; of symlinks?

2022-09-20 Thread Bakul Shah
On Sep 20, 2022, at 1:14 PM, Bakul Shah  wrote:
> 
> On Sep 20, 2022, at 8:18 AM, Tom R  wrote:
>> 
>> I would be ok with symlinks or hardlinks; but symlinks are better since I 
>> could
>> quickly find which folder the msg first landed in.
> 
> You can use a sequence to keep track of which folder a message came
> from. Then you just have to run a function like
> 
> msg2seq() { grep "\<$1\>" .mh_sequences|sed 's/:.*//'}
> 
> to reverse map a msg to the sequence(s) it is part of. One benefit
> is MH will maintain them properly as you rmm, sortm old messages etc.

Forgot to add: if you remove a message from a source folder,
your all folder will have a dangling symlink. This can be a
pro or a con depending on your PoV! Similarly if you move
messages around in the source folder, the symlinks will point
to the wrong messages.

Another way they help is you can define sequences day1..day31.
Then from cron you just have to delete today's sequence instead of
blowing everything away!





Re: 'all' folder msgs from last 3 weeks; of symlinks?

2022-09-20 Thread Tom R
thanks for the help Conrad and Ralph!

Hi Conrad:

On Tue 9/13/22 15:55 +0100 Conrad Hughes wrote:
>> I have many nmh folders, that get filled by procmail. I'd like to
>> have, an 'all' folder that is built by a shell script that could be
>> called by cron daily.  I'd be happy, with all msgs, say from the last
>> 21 days.
>
>Install mairix.  Then
>
>  mairix d:21d-
>
>will fill your +s (or whatever you choose to call it) folder with
>symlinks to emails from the last 21 days.  It'll do a whole lot more
>though since it's a general search engine.  It can even index compressed
>.mmdf archives: it's *great*.

I had mairix installed; and I was doing that -- except that I did not
have a script to easily update the list of all my folders.

I now have something to update ~/.mairixrc with a list of "all" my folders. 
I use something like:

find ~/Mail -mount -maxdepth 2 -type d -mtime -600 | perl -pe 
's~^.*?/Mail/?~~' | sort # ... pipeline continues ending in a ":" join


Hi Ralph:

On Tue 9/13/22 17:56 +0100 Ralph Corderoy wrote:
>> I have many nmh folders, that get filled by procmail. I'd like to have, an 
>> 'all'
>> folder that is built by a shell script that could be called by cron daily. 
>> I'd be happy, with all msgs, say from the last 21 days. Perhaps this script
>> would remove bad symlinks in 'all' each time it runs.
>
>You're implying you want the ‘files’ in +all to be symlinks rather than
>hard links?  refile(1) can make hard links with -link.

I would be ok with symlinks or hardlinks; but symlinks are better since I could
quickly find which folder the msg first landed in.

>I'd have thought useful parts would be:
>
>rmf +all
>folder -create +all
>
>folder +foo && pick -list -after -21 | xargs -rd\\n refile -link +all
>folder +bar && pick -list -after -21 | xargs -rd\\n refile -link +all

OK, so I would have to walk through all the folders one by one and run pick.

How about a soln something like

rmf +all
folder -create +all

find ~/Mail -mtime -21 -type f -not -empty -regextype posix-egrep -regex 
'.*/[0-9]+$' |xargs _addmsgs2-nmh-all-folder

sortm +all

Could the script _addmsgs2-nmh-all-folder use refile?  It seems refile does not
create soft links. I got the soft link thing from mairx I think -- nice because
I can find the orignal folder for the msg easily.

If _addmsgs2-nmh-all-folder did not use refile, my hunch
is I could "rmf +all;folder -create +all", then
add symlinks in naming the first "1", etc; then nmh would magically fix
.mh_sequences -- Right? When/how?  Maybe sortm +all would repair .mh_sequences?

>sortm +all
>
>If you want symlinks and you want to preserve +all from one run to the
>next but remove the symlinks to files which are now too old whilst
>adding those which are new then comm(1) would be handy.

ok, thanks, I've used comm from time to time. I'm ok with clobbering/rebuilding 
all though.

>> **In this way I could use sort and 'scan' to list the nmh 'all' folder
>> msgs sorted by time.**
>
>One has wondered about the separation of email files into folders and
>sequences, the overlap between the two, and most commands only working
>within a single folder.

Right. Maybe there should be a built in way to get at all msgs.

--
thanks,
Tom



Re: 'all' folder msgs from last 3 weeks; of symlinks?

2022-09-13 Thread Ralph Corderoy
Hi Tom,

> I have many nmh folders, that get filled by procmail. I'd like to have, an 
> 'all'
> folder that is built by a shell script that could be called by cron daily. 
> I'd be happy, with all msgs, say from the last 21 days. Perhaps this script
> would remove bad symlinks in 'all' each time it runs.

You're implying you want the ‘files’ in +all to be symlinks rather than
hard links?  refile(1) can make hard links with -link.

I'd have thought useful parts would be:

rmf +all
folder -create +all

folder +foo && pick -list -after -21 | xargs -rd\\n refile -link +all
folder +bar && pick -list -after -21 | xargs -rd\\n refile -link +all

sortm +all

If you want symlinks and you want to preserve +all from one run to the
next but remove the symlinks to files which are now too old whilst
adding those which are new then comm(1) would be handy.

> **In this way I could use sort and 'scan' to list the nmh 'all' folder
> msgs sorted by time.**

One has wondered about the separation of email files into folders and
sequences, the overlap between the two, and most commands only working
within a single folder.

-- 
Cheers, Ralph.



Re: 'all' folder msgs from last 3 weeks; of symlinks?

2022-09-13 Thread Conrad Hughes
> I have many nmh folders, that get filled by procmail. I'd like to
> have, an 'all' folder that is built by a shell script that could be
> called by cron daily.  I'd be happy, with all msgs, say from the last
> 21 days.

Install mairix.  Then

  mairix d:21d-

will fill your +s (or whatever you choose to call it) folder with
symlinks to emails from the last 21 days.  It'll do a whole lot more
though since it's a general search engine.  It can even index compressed
.mmdf archives: it's *great*.

Conrad



'all' folder msgs from last 3 weeks; of symlinks?

2022-09-13 Thread Tom R
I have many nmh folders, that get filled by procmail. I'd like to have, an 'all'
folder that is built by a shell script that could be called by cron daily. 
I'd be happy, with all msgs, say from the last 21 days. Perhaps this script
would remove bad symlinks in 'all' each time it runs.

**In this way I could use sort and 'scan' to list the nmh 'all' folder msgs 
sorted by time.**

Has someone already done this or the equivalent? Ideas/comments?

--
thanks,
Tom