if you want to use php, you'd need to use an exec or passthru function to access the unix shell (which would actually be renaming the files). you could write a bash program to do it but with php, code would be some thing like what follows. i've never tried it but it might be a helpful start.
<?php
$files = opendir("/dirpath/to/files/to/act/on/");
while (($current = readdir($files)) !== false) { //this while loop will act on each instance of $current
if (strpos($current, "shtml") && ($current!="index.shtml")!= FALSE){ //execpt if those two conditions are met
exec('mv $current $current.php'); //do this. could alternatly be a echo $current; for a file list
}
}
closedir($files);
?>
this would probably rename example.shtml example.shtml.php
you'd have to throw in a string_replace to beat that. see http://php.resourceindex.com/ for some prebuilt scripts; http://cgi.resourceindex.com/Programs_and_Scripts/ for versions in other languages. i've heard people asking about this kind of thing before so you shouldn't have too much trouble finding something.
go well