#!/usr/bin/perl

$oldpath = $ARGV[0];
$newpath = $ARGV[1];

system "find . -name \\*.shtml > list.txt";

open FILELIST, "list.txt" or die "can't open file list\n";

while($file =<FILELIST>){
	chomp($file);
	$fulltext = "";
	open FILE, $file or die "Can't open file $file\n";
	while ($line = <FILE>){
		
		$fulltext = $fulltext.$line;
	}
	
	$fulltext =~ s/$oldpath/$newpath/gs;
	
	$tempfile = $file;
	$tempfile =~ s/\.shtml/\.shtml.1/;
	open TEMPFILE , ">".$tempfile or die "Can't open $tempfile\n";

	print TEMPFILE $fulltext;
	close FILE;
	close TEMPFILE;
	
	system "rm $file";
	system "cp $tempfile $file";
}

close FILELIST;
system "rm list.txt";

