• # Vive les archives

    Posté par . En réponse au message Récuperer des emails de Evolution. Évalué à 1.

    Grâce au site www.archive.org j'ai pus accéder au script perl qui résout ce problème. Ça marche plutôt bien, j'ai pas perdu grand chose. Je colle le script entier ici au cas où...
    #!/usr/bin/perl
    # convert an evolution imap cache into a folder
    # Note: This version loses any status info stored in the .ev-summary file.
    $dir = $ARGV[0];
    $out = $ARGV[1];
    if ($dir eq "" || $out eq "") {
     print "Usage 0ドル inputdir outmboxfile\n";
     exit;
    }
    print "Processing dir $dir into mbox $out\n";
    open OUT,">>$out";
    foreach $file (`ls $dir | sort -n`) {
     chop $file;
     push @files, $file;
     $files{$file} = $file;
    }
    foreach $file (@files) {
     if ($file eq "." || $file eq "..") {
    	next;
     }
     print " $file\n";
     if ($file =~ m/^\d+\.$/) {
    	open IN,"<$dir/$file";
    	@body = ;
    	close IN;
    	print OUT "From -\n";
    	print OUT @body;
    	print OUT "\n";
     } elsif ($file =~ m/^(\d*)\.HEAD/) {
    	$base = 1ドル;
    	&add_body($base);
     } else {
    	print "skipping\n";
     }
    }
    sub add_body {
     my $base = $_[0];
     my $boundary;
     my @head, $head;
     my $n;
     my $name;
     my @pending, $pending;
     print "Adding body $base\n";
     if ($files{$base.".MIME"}) {
    	open IN,"<$base.MIME";
    	@head = ;
    	close IN;
    	print OUT @head;
     }
     if ($files{$base.".HEADER"}) {
    	$name = "$dir/$base.HEADER";
     } elsif ($files{$base}) {
    	open IN, "<$base";
    	@head = ;
    	close IN;
    	print OUT @head;
    	print OUT "\n";
    	return;
     } else {
    	print OUT "\nBody of message not found\n";
    	return;
     }
     open IN,"<$name";
     @head = ;
     close IN;
     $head = join("",@head);
     if ($head =~ m/boundary\s*=\s*\"([^\"]*)\"/is) {
    	$boundary = 1ドル;
     } elsif ($head =~ m/boundary\s*=\s*([\S]*)/si) {
    	$boundary = 1ドル;
     } else {
    	$boundary = "";
     }
     print "outputting head data $name\n";
     print OUT $head;
    # this is so we 'properly' insert missing parts.
     @pending = ();
     $n = 1;
     while ($n < 50) {
    	$name = $base.".".$n.".MIME";
    	if ($files{"$base.$n.MIME"} || $files{"$base.$n.HEADER"} || $files{"$base.$n"}) {
    	 push @pending, "$base.$n";
    	 foreach $pending (@pending) {
    		if ($boundary ne "") {
    		 print OUT "--$boundary\n";
    		}
    		add_body($pending);
    	 }
    	 @pending = ();
    	}
    	$n++;
     }
     if ($boundary ne "") {
    	print OUT "--$boundary--\n\n";
     }
    }