Rename to all lower script

This script will rename the file name you pass it to all lower case using tr

#!/bin/bash
# This script renames a file to lowercase
if [ "$1" = "" ]; then
echo "Must pass filename."
exit
fi
LOWERNAME="$(echo "$1" | tr '[A-Z]' '[a-z]')"
if [ $1 != $LOWERNAME ]; then
mv "$1" "$LOWERNAME"
ls -Al $LOWERNAME
fi
You can run it on multiple files in a directory with something like
for X in $(ls -1); do ./rename_lower.sh $X; done

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*