Você deve estar usando dirname
e basename
em vez desses truques com rev e cut
declare -l file_lower # anything assigned to this varname will be lower-cased
find $1 -type f | while read -r file
do
file_lower=$(basename "$file")
dir=$(dirname "$file")
mv "$file" "$dir/$file_lower"
done
find $1 -type d | sort -r | while read -r file
do
file_lower=$(basename "$file")
dir=$(dirname "$file")
mv "$file" "$dir/$file_lower"
done