<?php/* Initialize variables */$start = 1;/* Do not rename these files */$norename = array(".", "..", "rename.php");/* Directory to rename all files in it from one through how many files are in there. Include the trailing "/" */$dir = "Z:/Web Server/test/";/* Count number of files in $dir and check to make sure $dir exists and/or path is typed correctly */$count = 0;if(is_dir($dir)){ if($dh = opendir($dir)) { while(($file = readdir($dh)) !== false) $count++; closedir($dh); }}/* Rename files starting from $start (1) to $count (varies) */$filename = "";$ext = "";if(is_dir($dir)){ if($dh = opendir($dir)) { while(($file = readdir($dh)) !== false) { if(!in_array($file, $norename)) { $ext = end(explode(".", $file)); if(rename($file, $start.$ext)) { echo "File $file successfully renamed to $start.$ext.\n<br />\n"; $start++; } } } closedir($dh); }}else echo "The variable \$dir is invalid. Please check it.";?>