1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 00:02:29 +01:00
imapsync/learn/adjust_time.pl
Nick Bebout 3895b22b0a 1.140
2011-03-12 02:44:18 +00:00

47 lines
1.1 KiB
Perl

#! /usr/bin/perl -w
#
# Outlook (IMAP) manages mail dates from the creation date of the mail
# instead of the content of the field 'Date:', included into the mail.
# This script modifies the mtime of the mails, according to the 'Date:' field
# 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 /var/lib/vmail -type f -a -name '[0-9]*' > /tmp/toto
# Depending on the quality of the 'Date:' field, some mtime modification fails.
# 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, "</tmp/toto") or die "can't open toto";
@a = <F>;
chomp @a;
foreach $f (@a)
{
open(F1, "<$f") or die "can't open $f";
@b = <F1>;
chomp @b;
close F1;
@date = grep /^Date: /, @b;
next if scalar @date <= 0;
$d = $date[0];
$d =~ s/Date: (.*)$/$1/i;
print "$d\n";
@r = `/usr/bin/touch -md '$d' '$f' 2>&1`;
print "$f\n";
foreach $d (@r)
{
print "$d\n"
}
}