sysadmin:correggere_la_data_dei_file_maildir
Differences
This shows you the differences between two versions of the page.
| sysadmin:correggere_la_data_dei_file_maildir [11/06/2017 06:58] – external edit 127.0.0.1 | sysadmin:correggere_la_data_dei_file_maildir [20/12/2021 08:26] (current) – lrosa | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Correggere la data dei file maildir ====== | ||
| + | |||
| + | Nel formato maildir la data del file è la data del messaggio. | ||
| + | |||
| + | Se si copia il file potrebbe non rimanere la data giusta, questo script la sistema: | ||
| + | |||
| + | <code perl> | ||
| + | #! / | ||
| + | # | ||
| + | # Author : Jean-Yves Boisiaud | ||
| + | # | ||
| + | # Outlook (IMAP) manages mail dates from the creation date of the mail | ||
| + | # instead of the content of the field ' | ||
| + | # This script modifies the mtime of the mails, according to the ' | ||
| + | # value. | ||
| + | # Before running the script, you have to build a list of the mail files. | ||
| + | # For example, with the MailDir format, the file has been built whith : | ||
| + | # find / | ||
| + | # Depending on the quality of the ' | ||
| + | # You have to correct it manually. | ||
| + | # I ran it on 18733 mails, and 45 failed. | ||
| + | |||
| + | use strict; | ||
| + | |||
| + | my @a; | ||
| + | my $f; | ||
| + | my @b; | ||
| + | my @date; | ||
| + | my $d; | ||
| + | my @r; | ||
| + | my $s; | ||
| + | |||
| + | open(F, \"</ | ||
| + | @a = <F>; | ||
| + | chomp @a; | ||
| + | |||
| + | foreach $f (@a) | ||
| + | { | ||
| + | open(F1, \"< | ||
| + | @b = <F1>; | ||
| + | chomp @b; | ||
| + | close F1; | ||
| + | @date = grep /^Date: /, @b; | ||
| + | next if scalar @date <= 0; | ||
| + | $d = $date[0]; | ||
| + | $d =~ s/Date: (.*)$/$1/i; | ||
| + | print \" | ||
| + | @r = `/ | ||
| + | print \" | ||
| + | foreach $d (@r) | ||
| + | { | ||
| + | print \" | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
