slight fix (added quotes around the variable names to accomodate filepaths with spaces etc.). The next version of WeiDU will not need this but in the meantime:
#!/bin/sh
#
# drake127 (2006-03-15)
#
# Rename all files in current directory and all its subdirectories to lower-case.
# If lower-case filename already exists, more recent one is preserved.
# Support for filepaths with spaces added by Fyorl (2006-05-22)
for file in `find -depth | sed -e 's/\ /\\\ /g'`
do
replace=`dirname $file`/`basename $file | tr [:upper:] [:lower:]`
if test $file != $replace -a $file != .
then
mv -u $file `dirname $file`/`basename $file | tr [:upper:] [:lower:]`
rm -f $file
fi
done
UPDATE:
*sigh* scratch that, it doesn't work but give me a minute
UPDATE #2
I'm fighting a losing battle here, the damn 'for file' keeps assigning a new $file every time it hits a space, even if that space is escaped >_<.
UPDATE #3
I give up. If you want, you can use this PHP script that I wrote which will do the trick just fine, but I doubt many people have PHP installed.
#!/usr/bin/php
<?php
# by Fyorl
# makes all files in the current directory (recursive) lowercase
$dir = `dirname $argv[0]`;
$dir = trim($dir);
to_lower($dir);
function to_lower($dir)
{
$handle = opendir($dir);
while(false !== ($file = readdir($handle)))
{
$fp = $dir . '/' . $file;
if($file == '.' || $file == '..')
{
continue;
}
$fpl = strtolower($fp);
if($fp != $fpl)
{
exec("mv -u '$fp' '$fpl'; rm -f '$fp'");
}
if(is_dir($fpl))
{
to_lower($fpl);
}
}
}
?>