Rename Files Into All Lowercase

October 30, 2006 | PHP

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!

 

1 comment

This post has one comment

  1. jelle 25/06/2008 at 14:31

    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 comment

Allowed tags are: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>