procmail
[Top] [All Lists]

Re: Adding date to file name

1999-06-24 06:22:40
Larry Wright wrote,

W> I checked the past messages & the faq. They mostly address getting data
W> from the line. As I see it, the problem is in correctly getting and then
W> formatting the data one would get from the From_ line into YYMMDD format.
W> Any suggestions much appreciated.

First suggestion: make it YYYYMMDD format, or your sorting will break as we
cross from December, 1999, to January, 2000.

OK, here we go.  Let's try something like this:

 :0
 * ! ^^From +[^ ]+ +(Sun|Mon|Tue|Wed|Thu|Fri|Sat) +\/[ADFJMNOS].+
 { YYYYMMDD=00000000 }
 :0E
 {
  monthdatetimeyear=$MATCH

  :0
  * monthdatetimeyear ?? ^^\/...
  { monthabb=$MATCH }

  # sleazy translation trick, my own invention, thank you
  monthstring=Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12

  :0
  * $ monthstring ?? $monthabb\/..
  { MM=$MATCH }
  :0E
  { MM=00 }

  :0
  * ! $ monthdatetimeyear ?? $monthabb +\/[0-9].*
  { YYYYMMDD=00000000 }
  :0E
  {
   datetimeyear=$MATCH

   :0
   * ! datetimeyear ?? ^^\/[0-9]+
   { DD=00 }
   :0E
   { DD=$MATCH }
   :0A
   * DD ?? ^^.^^
   { DD=0$DD }

   :0
   * ! datetimeyear ?? :.. +\/[0-9]+
   { YYYY=0000 }
   :0E
   { YYYY=$MATCH }

   YYYYMMDD=$YYYY$MM$DD
  }
 }

Era suggested to Larry, to make up for his lack of cron access,

E> Or be a Sunday anarchist: Get a different account where you do get to
E> run cron, schedule it to send a token mail to this account, where it
E> gets intercepted by Procmail, which then proceeds to do the actual
E> processing you want done.

A Billy Sunday anarchist?  Anyhow, many webmail services and search engines
and the like come with calendar functions.  If you can't get true cron access,
you can set up repeating calendar events with reminders to be mailed to your
main account, which procmail can snag as triggers for the tasks you would
normally run from a crontab.

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