procmail
[Top] [All Lists]

Re: converting .procmailrc that used to work with mailbox format to one that supports maildir

2009-01-21 07:21:19
Am 2009-01-20 21:45:27, schrieb Ariel Biener:
1. Convert the folder names for delivery to maildir format,
  a. Replace any "." in the folder name with "_"
  b. Replace any "/" in the folder name with a "." (except for folder 

----8<------------------------------------------------------------------
#!/bin/sh
# 
# Copyright 2009, Michelle Konzack <linux4michelle(_at_)tamay-dogan(_dot_)net>
# 
# This files was rapidely hacked and comes WITHOUT any warranty.
# 
# You are free to use it as you like.
# 

# Build a list of RC files
INCLUDERCS="~/.procmailrc $(grep 'INCLUDERC=' ~/.procmailrc |sed -e 
's|.*NCLUDERC=||g')"

# Create the new Maildir
mkdir -p ~/Maildir/{tmp,new,cur}

cd ~/Mail

# Find all MBOX files in the directory
for MBOX in $(find -type f -name '*.mbx') ; do

  # Transform the Mailbox PATH into an doted courier PATH
  NEWNAME=$(echo "${MBOX}" |sed -e 's|.mbx$||' -e 's|^\./|.|' |tr '/' '.')
  # Create the NEW mailfolder
  mkdir -p ${NEWNAME}/{tmp,cur,new}

  PNAME=$(echo "${MBOX}" |sed -e 's|^\./|.|')
  # Work on all RC files
  for RCFILE in ${INCLUDERCS} ; do
    # If MBOX path was found...
    grep "${PNAME}" ${RCFILE} >/dev/null 2>&1
    if [ $? -eq 0 ] ; then
      # ...edit the RC file
      sed "s|${PNAME}|${NEWNAME}/|g" ${RCFILE} >${RCFILE}.tmp
      if [ $? -eq 0 ] ; then
        mv ${RCFILE}.tmp ${RCFILE}
      else
        exit 1
      fi
    fi
  done

  # If all RC files are edited, create a temporary one
  echo "MAILDIR=\${HOME}/Maildir"        >~/procmailrc.tmp
  echo "DEFAULT=\${MAILDIR}/"           >>~/procmailrc.tmp
  echo ""                               >>~/procmailrc.tmp
  echo ":0"                             >>~/procmailrc.tmp
  echo "${NEWNAME}"                     >>~/procmailrc.tmp

  # Convert the MBOX file into Maildir
  formail -ds procmail <${MBOX}

  rm -f ~/procmailrc.tmp

done
----8<------------------------------------------------------------------


/dev/null)
  c. Add a "." as the beginning of the foldername.
  d. Append a "/" at the end of the foldername.
2. Replace the MAILDIR variable to be MAILDIR=$HOME/Maildir/
3. (optional) If a include directive is found in the .procmailrc file, 
then it should
   read the included file and fix it as well based in 1. and 2.

I've seen all kinds of recipes, but none does everything I described 
properly.

Does anyone have or know of such recipe/script/converter ?


best,

--Ariel 
--
Ariel Biener, CISO
Tel-Aviv University CIT div.
e-mail: ariel(_at_)aristo(_dot_)tau(_dot_)ac(_dot_)il phone: 03-6406086
PGP key:    http://www.tau.ac.il/~ariel/pgp.html

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

------------------------ END OF REPLIED MESSAGE ------------------------
************************************************************************
*       Do not Cc: me, because I READ THIS LIST, if I write here       *
*    Keine Cc: am mich, ich LESE DIESE LISTE wenn ich hier schreibe    *
************************************************************************

Hello,


Thanks, Greetings and nice Day/Evening
    Michelle Konzack
    Systemadministrator
    24V Electronic Engineer
    Tamay Dogan Network
    Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
<http://www.tamay-dogan.net/>               <http://www.can4linux.org/>
Michelle Konzack   Apt. 917                  ICQ #328449886
+49/177/9351947    50, rue de Soultz         MSN LinuxMichi
+33/6/61925193     67100 Strasbourg/France   IRC #Debian (irc.icq.com)


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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