Call us Toll-Free:
1-800-218-1525
Email us

 Sponsors

phpX Converter

Code Wizard, 12-30-2006

The dispayed script renames all files in a given directory to and from the given extions for your convenience

<?php

/*

***********************************************
-[ phpX Converter v0.1-dev (Initial Release) ]-
***********************************************
-[ Author: Andrew Heebner ]-
-[ Email: andrew@phplovers.org ]-
***********************************************

This script was created in place of an SH server
script that was needed by a user to replace all
of their *.php3 files with *.php extensions,
without having to manually rename all the files
and not having to use a server side script.

***********************************************
*** Covered and protected under the GPL ***
***********************************************

Usage:
rename.php?&ext_old=php3&ext_new=php&dir=/home/http/site/here

*/


if(empty($ext_old) && empty($ext_new) && empty($dir)) {
$ext_old = "php3";
$ext_new = "php";
$curdir = ".";
}

$handle = opendir($dir);
while($file = readdir($handle) <> false) {
if($file != "." && $file != "..") {
if(is_file($file) && $old_file = substr($file,-4)) {
if($old_file == $ext_old) {
$new_file = substr($old_file,-(strlen($ext_old)) . $ext_new;
if(rename($old_file,$new_file) <> false) {
print "<br><b>$old_file</b> -> <b>$new_file</b><br>";
} else {
print "Rename failed";
}
}
}
}
}

closedir($handle);

?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions