This script recursively scans through your directories and changes file extensions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
/* --------------------------------------------------------------- EXTchange 0.01 - File extension changer (c)2001 Philip Iezzi, https://www.iezzi.ch last modified : 06/04/2001 This script recursively scans through your directories and changes file extensions. --------------------------------------------------------------- */ /*-----------------------------------------*/ $old_ext = 'php3'; // your old extension $new_ext = 'php'; // your new extension $start_dir = ''; // directory to start /*-----------------------------------------*/ function directoryList ($url) { $surl = $url; $i = 0; if (substr($url,0,1) == '/') $surl = substr($url,1); $d = opendir($surl); while($entry=readdir($d)) { if ($entry != "." && $entry != "..") { $outp[$i] = $entry; ++$i; } } closedir($d); return $outp; } function list_files($path) { global $old_ext, $new_ext; $path_array = directoryList($path); for($i=0; $i < count($path_array); $i++) { if ($path > '') $p = '/'; else $p = ''; $fd = $path.$p.$path_array[$i]; if (@is_dir($fd)) list_files($fd); else if (preg_match('/\.'.$old_ext.'$/i', $fd)) { $fd_new = substr($fd, 0, strlen($fd)-strlen($old_ext)).$new_ext; rename ($fd, $fd_new); echo $fd.' >>> '.$fd_new.' '; } } } list_files($start_dir);</blockquote> |