Rename Files Into All Lowercase

I wrote this script when my Windows 98 screwed up my filename. It was index.php and changed into Index.php, in a big number of files within a directory :(

// I name it caser.php
$handle = opendir($argv[1]);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
rename("$argv[1]/$file",strtolower("$argv[1]/$file"));
echo "$file renamed
";
}
}
closedir($handle);
?>

Usage:
C:php4> php.exe caser.php c:apachehtdocs [enter]

Have fun!

 

One Response to “Rename Files Into All Lowercase”

  1. jelle Says:

    Hey hey

    Should be precisely what im looking for. although im such a noob that i dont know how to use this … :(

    Copy this to notepad, save as .php…
    but how does “C:php4> php.exe caser.php c:apachehtdocs [enter]” this work ?

Leave a Reply