On Thu, 31 Jul 2003, Peter C. Norton wrote:
( echo "#!/bin/bash"
[ "x" = "x$1" ] && exit
echo "touch -d \"\$( egrep '^Date: ' $1 | head -1 | sed 's/^Date: //')\" $1' ) >> /tmp/timechange.sh
chmod +x /tmp/timechange.sh
find /path/to/maildirs -type f | xargs -n 1 /tmp/timechange.sh
This is untested, and it won't be fast, but if you only need to do it once then it should work.
<blush> Yikes, that was very easy. I had to modify it a little bit but it
did the trick. Thanks very much. Actually, though, it turns out that I
asked the wrong question. As far as I can tell, the issue is the actual
file names (not file dates) of the messages. The bottom line, it appears,
is the default order in which messages are presented by the IMAP server,
which I believe is by the order of the file names (same order a standard
'ls' in the maildir would display them). So, I'd need to actually change
file names around to get them into order. I'm sure I could just rename
them, but obviously the names generated by Courier provide some
optimization--I don't know all the details, but I know that the names
include the message size and other info (looks like message IDs or
something, though I don't find the same strings inside the message
itself). So, I don't want to mess all that up.
Any *quick* ideas for how to rename the files with the appropriate ID
codes (or whatever is included in the names) automatically? As I said,
this is not a big deal, and I really don't want to get everybody to do my
work for me, especially if it turns out not to be trivial for the experts.
If I had to, I could always look at Courier's source to see how it is
naming and write my own utility, but again I just thought that in the
interest of time somebody else might have a quicker, clever way (usually
the case). Thanks a bunch in any case.
I'm not sure this is going to do what you want -- because I'm not really sure what you want, since Courier doesn't present the filenames (or any date information in them) to the clients, at least not AFAIK.
But if you really want to change the filename to reflect when the message arrived in the mailbox originally... Then you can just take the first "Received:" header in a message (i.e. the last one added) and convert the date at the end of that to a time()-compatible value. That value can then simply replace the first segment (i.e. before the first dot) in the filename of the message.
(Good luck grabbing the first instance with a regexp cleanly though, since you can't count on it being on one line, since it rarely is, nor on which header follows it, nor on much of anything except that the date is at the end of that header. -- Maybe try un-folding the headers yourself before using the regexp. Doing that first would make it fairly simple to locate, I think. When unfolded something like /^Received: .*; (.*)/ should get you the date, I believe. Because I think there's always a semi-colon before the date in a received header.)
Anyway... Are you sure that's what you are trying to fix though? Like I said, I don't think Courier passes that information (from the filename) on to any clients. I believe it only passes on 2 types of date information: a) the INTERNALDATE property of the message (which should be when it arrived anyway, but might get changed in some situations) and which Courier stores in the modification time of the file (not the filename), and b) the date strings embedded in the message itself.
So, I actually don't see how this is going to help your situation. Maybe a more precise description of what behavior you *are* seeing, and what you'd *like* to see instead, would help someone come up with a more useful suggestion. 'Cause I don't think this is really what you're looking for either.
-jab
P.S. Oh, btw... If you do muck around with filenames, you'll lose your current UID associations. (Will anything else get lost, guys?). Just though I'd point that out, in case it's important to you at all.
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ courier-users mailing list [EMAIL PROTECTED] Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users
