procmail
[Top] [All Lists]

Splitting a VM mail folder into component messages

1996-10-03 18:06:15
Hi All-

I've got a rather large VM mail folder (has 266 messages) that I'd
like to break up into one email message per file, and put them all
into a subdirectory.  

I'd like it if I could arrange this procedure so that each file gets
named according to some rule that depends on the contents of the file
and thus the message that it contains (ie, for any file containing a
single message, the filename is either the contents of the Date:
field, a concatenation of the Subject: and Date: fields together, or
maybe the Subject: field concatenated with the $FILENO variable that's
mentioned in the formail(1) manpage.

It seems that formail would be the best tool for such a task, but I'm
having a problem with the details.

I know that according to the manpage, when I use

formail -s 

then I can follow the "-s" with a program that should be executed for
each message, so I know I'll be wanting to use this option, but I
don't know what program to use.  All I want to do is redirect the
output (message by message) to some file (a different file for each
message), so it seems like I should just use the redirection
operators, but then the manpage says that if I omit the program name
following the "-s", then all of the output just gets sent to stdout.

I also have been able to figure out that doing things like

formail -zx Subject: -s < foldername

will get me the subject of each message, but then I need to use that
content to create a file with the message contents in that file.  I
thought of storing it in a variable or something, but I guess I lack
experience, because it's failing in various ways.  I'm also not sure
if this (formail -zx Subject: -s < foldername) will _just_ get me the
subjects.  If so, then this is not what I want, because I want the
entire message's contents to go into it's own file.

The other thing I have to look out for is that because this folder has
correspondence between me and another person over several months, many
of the messages have identical subjects from doing several "Re: this"
and "Re: that" iterations, so I can't just have the Subject: field
contents be the only rule used to name each file or else I'll end up
writing over already created files.  However, it would be desirable to
have the Subject: field contents be a part of each filename so that
the filename would give a hint as to the file's contents.

I guess I also have to be concerned about spaces in the filename, but
I believe that it should work ok to have space in filenames as long as
I quote these filenames-containing-spaces whenever I refer to them.

I'd really appreciate it if somebody could post a few suggestions on
how to accomplish this goal I have.  Sorry if this is a newbie
question, but it's only just recently that I've installed procmail,
formail, etc. and I've got no experience using these tools.

Thanks very much for any advice.


___________________________________________________________________________
 Plan ahead.  Promote swift colonization of the solar system...  *First* 
____________________________________________
__________________

"When you are in it up to your ears, keep your mouth shut."

_______________________
____________Kevin S Ford__________
_____________ksford(_at_)nps(_dot_)navy(_dot_)mil________



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