Here is what I do by hand (stupid, by definition). - Have a list of file names in a folder on my server. - The names are meaningless, but they are in a consistent format, like this: - _Scar10_Phtml.static - _Scar11_Phtml.static .....and so on - These are the only files in this folder. - Every file in the folder needs to be renamed as follows: - Open the file - Grab what is between the <title> tags - Remove Extraneous spaces, make it all lower case, then add dashes between the words - Copy the file using the cleaned up stuff found between the <title> tags as the name - Change the file extension to .php For example: If the file called " _Scar10_Phtml.static " has this title info: <title> Antique Kookoo Clock for sale </title> then the file gets copied and renamed this: " antique-kookoo-clock-for-sale.php ". So, if the folder starts with 500 meaningless file names it would end up with 1,000 files total in it (500 with the original whacky name and 500 with the new, sexy names derived from the title tags.) That is it. Must run on steam powered php version 4 dot old. Don't use any fancy php 5 syntax, most of my $5 per month servers have the old stuff. Please PM me with a fixed price and time frame for completion. Once I accept your offer I will send you some files for you to work with. Payment immediately follows successful install by me on one of my cheapie servers. This would take me all freaking day poking around my "PHP for Dumbasses" book...or one of you pros can bang it out in no time. Thanks for having a look.
use this: (but you'll need to have write permission to that folder.) <?php echo "<pre>"; if ($handle = opendir('.')) { echo "Directory handle: $handle\n"; echo "Files:\n"; // List all the files while (false !== ($file = readdir($handle))) { //if ($file != "." && $file != ".."){ if (substr($file,-7) == ".static"){ echo "$file"; $content = file_get_contents($file); if (eregi('<title>(.*)</title>', $content, $results)) { $result = $results[1]; $filename = strip($result).".php"; echo " => ". $filename ."\n"; if (!$h = fopen($filename, 'w')) { echo "Cannot open file ($filename)"; exit; } fwrite($h,$content); fclose($h); } } } closedir($handle); } function strip($string){ $pattern = "([[:punct:]])+"; $anchor = ereg_replace($pattern, '', strtolower($string)); //echo $anchor; $pattern = "([[:space:]]|[[:blank:]])+"; $anchor = ereg_replace($pattern, '-', $anchor); return $anchor; } # end function ?> PHP: