Anthony Caetano wrote:

> I am looking for a way to stay "current" without mirroring an entire site.

[snip]
> Does anyone else see a use for this?

Yes. Here's my non-wget solution. I truncate all the files in the
directories that I don't want, but maintain the date/time accessed and
modified. The Perl script I use follows. --Tony

#!/usr/bin/perl

$dir = shift @ARGV;
die "No such directory: $dir\n" unless -d $dir;

$nFiles = 0;
my @dirs = ($dir);
while (scalar(@dirs)) {
  processDir(shift @dirs);
}
print "Truncated $nFiles files.\n";

sub processDir
{
  my ($dir) = @_;
  opendir DIR, $dir or die "Cannot read directory: $dir\n";
  foreach $file (readdir DIR)
  {
    next if $file eq "." || $file eq "..";

    $path = "$dir/$file";
    if (-d $path) {
      push @dirs, $path;
    } else {
      my @stat = stat($path);
      $nFiles++;
      open F, ">$path" or next;
      close F;
      utime $stat[8], $stat[9], $path;
    }
  }
  closedir DIR;
} 


Reply via email to