Lowercase the names of all files in a directory (defaults to current directory).
#!/bin/bash
echo
path="."
counter=0
remainder=0
if [ ! -z "$1" ]; then
path="$1"
fi
echo "Lowercase File Names"
echo " > Getting file list"
# Get a list of files
files=`ls -1 $path`
# Get a file count
fc=`ls -1 $path | wc -l`
remainder=$fc
echo " > Renaming $fc files"
for f in $files; do
# Keep track of our iteration so long operations
# don't seem like they're hung/frozen
((counter++))
((remainder--))
if [ $((counter%2)) -eq 0 ]; then
echo " - $remainder remaining"
fi
# Get the lowercased name of the file
fl=`echo "$f" | awk '{print tolower($f)}'`
# Rename the file
mv "$f" "$fl"
done