At 14:44 2003-11-05 -0800, Bryan Koschmann - GKT wrote:
So, say the message for today is called "SIGNUP REPORTS 11/5/2003" and has
7 jpgs, all named odd names (file1.jpg, 7223.jpg, etc). They would
automatically be saved to an attachment directory and named
"file1-11052003.jpg" and "7223-11052003".
You _could_ instead save them to a subdirectory within the attachment
directory:
attach/YYYYMMDD/file1
attach/YYYYMMDD/7223
Should be doable by creating a date-named directory (see 'man procmailex')
then chdiring into it and piping the message to mimencode with the
appropriate options.
ATTACH=$HOME/attach/
:0c
* some condition
{
# Obtain the date (for automatic month-based archives)
MONTHFOLDER=${ATTACH}`date \+"%Y%m"`
# if dir doesn't _already_ exist, create it.
:0
* ? test ! -d ${MONTHFOLDER}
{
:Wic:MONTHFOLDER$LOCKEXT
* ! MONTHFOLDER ?? ^^^^
| mkdir -p $MONTHFOLDER
}
:0
| my_metamail.sh $MONTHFOLDER
}
where my_metamail.sh contains:
#!/bin/sh
#
METAMAIL_TMPDIR=$1
export METAMAIL_TMPDIR
metamail -w -x
Alternatley, the invoked shell script could deal with extracting the
attachments to a temporary directory and then move or rename them as desired.
:0 ci
* ^Content-type:.*multipart/mixed
* B ?? Content-transfer-encoding:.*(x-uuencode|base64)
| /usr/local/bin/munpack -q -C ~/attach/
I'm not familiar with munpack, but if this deals with extraction, why not
invoke it from a shell script and deal with your file renaming? you'll
*HAVE* to deal with the renaming outside of procmail anyway.
---
Sean B. Straw / Professional Software Engineering
Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
Please DO NOT carbon me on list replies. I'll get my copy from the list.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail