procmail
[Top] [All Lists]

Re: the term "sorting"

2000-07-05 08:01:05
Hi David!

Thanks for the insight on trying to solve my problem. I thought about doing what you suggested.

Would I use formail to save all the messages (I guess I'll use received date) into separate files and then just dump them back into my system mailbox.

Also, in order to get that date, would I grep/awk/cut each message for it and then feed it to the date command?

Many thanks,
Jason.


--On Friday, June 30, 2000 10:50 -0500 David W. Tamkin deftly scribbled:
Jason explained,

I thought "sorted by date" was a big clue as to what I wanted to do!
Just  in case it's still not clear. I would like to *sequence* my mail
by date.

Thank you.  Yes, it was a big clue, and that's why I said that the
Thursday post (yours) was probably about sequencing.

So you asked,

| I have a large archive of mail that I access via IMAP. I have been
merging  | mail from various other archives and systems I have used over
time and  | would like to get the IMAP archives sorted by date. Currently
they are  | sorted by the order in which they were added to the archive.

| What this means is that when I want to go back to a certain period in
time,  | I have to select sort by date in my mail client which as can be
imagined  | takes a long time to load the message headers of several
thousand messages  | via IMAP and then sort them.

| What I need to do is run a sort on these messages on the server side
during  | the night. Has anybody done anything like this?

And I see that I shot my mouth off too much when I said I had answers to
offer once the ambiguity was cleared up, because your question is specific
to IMAP and I had forgotten that.  So I defer to Bart Schaefer.

If your client can deal with an mbox on the server, then I would have had
an answer for sequencing the messages.  But Bart's response opens a door:

: If you physically reorder the messages "behind the server's back" the
best : that will happen is that the server will have to reassign all the
UIDs; : the worst is that it'll break entirely.

: The only correct way to do this within the IMAP protocol is to copy the
: messages one by one in the desired order into a new mailbox, then delete
: the old mailbox and rename the new one.  I say "one by one" because if
you : supply a range of numbers to the COPY command, the IMAP server is
allowed : to decide the order in which it copies them, which defeats your
purpose.

One way that has worked for me, dealing with mboxes rather than IMAP
folders, has been to save each message to a file named for the date +%s
(GNU date sup- ports that) equivalent of its timestamp.  Now, I don't
know whether, when you say "sorted by date," Jason, you mean by date sent
rather than date received. [Since they are merges from many delivery
locations, they didn't start out in order of receipt.]  If you want to
sort them by date sent, that has an inherent complication: senders often
have their system time and date set wrong, or their mail clients use the
time zone indicator, an invalid one, or a mnemonic for the time zone that
matches that for another time zone nearer you.  Thus the date sent
information is often unreliable or inaccurate.  (It wasn't a problem for
me, because I was re-sorting by the date and time of receipt per the
From_ line to get messages back into their original sequence of arrival
after I had moved them around, so I was taking dates and times out of the
From_ lines,  All the From_ lines were added by the local host, so they
were in a consistent format.)

So, after saving every message to a file named for the number of seconds
from the Unix epoch to its own date, I let the shell sequence them with

  cat working_directory/* > new_folder

While you would re-feed them to IMAP to get them renumbered in the order
you want (as Bart described) rather than concatenating them to a new mbox
as I did, perhaps this can still be of some value for your situation.

Good luck.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail






_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>