#!/usr/bin/perl # restore_dates.pl -- author: Oliver Bossert # Copyright (C) 2004 Oliver Bossert # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use strict; use warnings; use File::Find; use Digest::MD5; my %data = (); my $FILE = ".savedates"; open (F1, ".savedates") or die "Could not read file!"; while() { chomp; my @a = split /\s+/, $_; $data{$a[0]}->{md5} = $a[1]; $data{$a[0]}->{at} = $a[2]; $data{$a[0]}->{mt} = $a[3]; } close F1; find sub { my $omd5 = Digest::MD5->new; open(F, $_) or die "Can't open '$_': $!"; binmode(F); while () { $_ =~ s/date\" content=\"[^\"]+\"//; $omd5->add($_); } my $md5 = $omd5->b64digest; #Digest::MD5->new->addfile(*F)->hexdigest; close F; if (defined($data{$File::Find::name}) && $md5 eq $data{$File::Find::name}->{md5} ) { utime($data{$File::Find::name}->{at}, $data{$File::Find::name}->{mt}, $File::Find::name); } else { print $File::Find::name . " was modified: " .$md5 . " != " . $data{$File::Find::name}->{md5} . "...\n"; } }, ".";