Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
809 connectés 

  FORUM HardWare.fr
  Linux et OS Alternatifs
  Divers

  Conversion mailbox - maildir

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Conversion mailbox - maildir

n°376575
Profil sup​primé
Posté le 18-12-2003 à 17:39:01  answer
 

Salut !
 
Le pb est le suivant : on a tout un tas de mailboxes à covnertir en maildir.
 
je suppose qu'un utilitaire existe pr cela, mais devant le flot d'informations délivrées par google je 'nai rien pu trouver de très pertinent...
 
merci d'avance pr votre aide :)

mood
Publicité
Posté le 18-12-2003 à 17:39:01  profilanswer
 

n°376585
mikala
Souviens toi du 5 Novembre...
Posté le 18-12-2003 à 18:10:12  profilanswer
 

perfectmailbox ?  

Code :
  1. #!/usr/bin/perl
  2. # "Simple but Perfect" mbox to Maildir converter v0.1
  3. # by Philip Mak <pmak@aaanime.net>
  4. # Usage: perfect_maildir ~/Maildir < mbox
  5. # Simple  - only converts one mbox (can use script in one-liners)
  6. # Perfect - message Flags/X-Flags are converted; "^>From ." line is unescaped
  7. # I wrote this script after being unsatisfied with existing mbox to
  8. # maildir converters. By making it "Simple", code complexity is kept
  9. # low thus making it easy to program and debug. At the same time,
  10. # since it only converts one mbox at a time, it is perfect for use in
  11. # a shell ``for'' loop (for example).
  12. # As for being "Perfect", to the best of my knowledge this script does
  13. # the conversion correctly in all cases; it will translate "Status"
  14. # and "X-Status" fields into maildir info, and it correctly detects
  15. # where messages begin and end. (This is only version 0.1 so I may
  16. # have messed something up though. Please send me feedback!)
  17. # NOTE: The MUA ``mutt'' has a bug/feature where in the message index,
  18. # it claims that all maildir messages have 0 lines unless they have a
  19. # "Lines:" header set. perfect_maildir does not attempt to add the
  20. # "Lines:" header; you may want to reconfigure ``mutt' to display byte
  21. # size instead of lines instead by adding the following line to your
  22. # ~/.muttrc file:
  23. #
  24. # set index_format="%4C %Z %{%b %d} %-15.15L (%4c) %s"
  25. # check for valid arguments
  26. my ($maildir) = @ARGV;
  27. if (!$maildir) {
  28.   print STDERR "Usage: perfect_maildir ~/Maildir < mbox\n";
  29.     exit 1;
  30.     }
  31.     # check for writable maildir
  32.     unless (-w "$maildir/cur" ) {
  33.       print STDERR "Cannot write to $maildir/cur\n";
  34.         exit 1;
  35. }
  36. unless (-w "$maildir/new" ) {
  37.   print STDERR "Cannot write to $maildir/new\n";
  38.     exit 1;
  39.     }
  40.     my $num = 0;
  41.     my $time = time;
  42.     repeat:
  43.     # read header
  44.     my $headers = '';
  45.     my $flags = '';
  46.     my $subject = '';
  47.     while (my $line = <STDIN> ) {
  48.       # detect end of headers
  49.         last if $line eq "\n";
  50.    # strip "From" line from header
  51.      $headers .= $line unless $line =~ /^From ./;
  52.        # detect flags
  53.          $flags .= $1 if $line =~ /^Status: ([A-Z]+)/;
  54.     $flags .= $1 if $line =~ /^X-Status: ([A-Z]+)/;
  55.       $subject = $1 if $line =~ /^Subject: (.*)$/;
  56.       }
  57.       $num++;
  58.       # open output file
  59.       my $file;
  60.       if ($flags =~ /O/) {
  61.         $file = "$maildir/cur/$time.$num.$ENV{HOSTNAME}";
  62.           my $extra = '';
  63.      $extra .= 'F' if $flags =~ /F/; # flagged
  64.        $extra .= 'R' if $flags =~ /A/; # replied
  65.          $extra .= 'S' if $flags =~ /R/; # seen
  66.            $extra .= 'T' if $flags =~ /D/; # trashed
  67.       $file .= ":2,$extra" if $extra;
  68.       } else {
  69.         $file = "$maildir/new/$time.$num.$ENV{HOSTNAME}";
  70.         }
  71.         # filter out the "DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA" message
  72.         $file = '/dev/null' if ($num == 1 and $subject eq "DON'T DELETE THIS MESSAGE -- FOLDER
  73.         INTERNAL DATA" );
  74.         open(FILE, ">$file" );
  75.         print FILE "$headers\n";
  76.         while (my $line = <STDIN> ) {
  77.           # detect end of message
  78.             last if $line =~ /^From ./;
  79.        # unescape "From"
  80.          $line =~ s/^>From (.)/From $1/;
  81.            print FILE $line;
  82.            }
  83.            close(FILE);
  84.            goto repeat unless eof(STDIN);
  85.            my $elapsed = time - $time;
  86.            print "Inserted $num messages into maildir $maildir in $elapsed seconds\n";



Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs
  Divers

  Conversion mailbox - maildir

 

Sujets relatifs
Conversion de l'encodage des noms de fichiersSoft de conversion (asf -> avi/mpeg) ça existe ?
Exim4 + Maildir + imap[Mozilla]Boite au format mailbox
conversion FAT32 -> ext3 /GNU parted / qq'un maîtrise ?qmail, vpopmail et maildir est-ce que quelqu un a cette config
conversion grosse partoche fat32 -> ext3Conversion NTFS => FAT
Conf d' exim pour maildirconversion fichiers audio WMA --> WAV
Plus de sujets relatifs à : Conversion mailbox - maildir


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR