Here's an example of it working...
Code:
[frozen@Fr0ZeN scripts]$ ls test
file space lowercasefile n FILE sPAcE normaldir/ UppER SpAcES DIR/ with spaces dir/
[frozen@Fr0ZeN scripts]$ ./utol test
[frozen@Fr0ZeN scripts]$ ls test
file space lowercasefile n file space normaldir/ upper spaces dir/ with spaces dir/
Finally, here's the code:
Code:
#!/bin/sh
#
# Rename all files and directories within a directory to have lowercase letters
# + skips over files that lack upper case letters
# - non recursive, possibly just add "-R" to 'ls'
#
# (c) 2003 Kyle Gibson, free for non-commercial use
# may be redistributed provided this header is left
# in tact. Feel free to modify.
#
# License: GPL
##################################
usage()
{
echo "Usage: $0 [directory]"
exit 1;
}
test -d "$1" || usage
DIR="$1"
ls "$DIR" | grep -e "[A-Z]" | \
while read file; do
N=`echo -n "$file" | tr "[:upper:]" "[:lower:]"`
mv "$DIR/$file" "$DIR/$N"
done