Log in

No account? Create an account
entries friends calendar profile My Website Previous Previous Next Next
Mark Atwood
Perl script set-date-on-article
A quick-n-dirty bit of Perl I've meant to write for years now.

Give it a list of filenames that contain kindasorta RFC822ish text, and it will "touch" each file so that it's filesystem timestamp matches the "Date:" header.

use Date::Manip;
foreach $f (@ARGV) {
unless (open(F, $f)) { print STDERR "fail open $f: $!\n"; next; }
read(F, $t, 8192);
close F;
if ($t =~ m/\nDate: ([^\n]*)\n/) {
$d = $1;
$secs = UnixDate($d,"%s");
unless (utime($secs, $secs, $f))
{ print STDERR "fail utime $secs $f\n"; }
} else {
print STDERR "fail parse $f: No Date header\n";

Tags: , ,
Current Location: Online Coffee 3, Capitol Hill, Seattle WA

Leave a comment