31 lines
577 B
Bash
Executable File
31 lines
577 B
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] ; then
|
|
cat<<EOF
|
|
Usage: ${1##*/} FILES
|
|
|
|
Rename FILES to lowercase.
|
|
|
|
EOF
|
|
fi
|
|
|
|
for FILE ; do
|
|
FILENAME=${FILE##*/}
|
|
|
|
case "$FILENAME" in
|
|
*/*) DIRNAME="${FILE%/*}" ;;
|
|
*) DIRNAME="." ;;
|
|
esac
|
|
|
|
NF="$(echo $FILENAME | tr '[:upper:]' '[:lower:]')"
|
|
NEWNAME="${DIRNAME}/${NF}"
|
|
if [ "$NF" != "$FILENAME" ]; then
|
|
if [ -e "$NEWNAME" ]; then
|
|
echo >&2 "$NEWNAME already exists, not overwriting."
|
|
else
|
|
mv "$FILE" "$NEWNAME"
|
|
echo "'$FILE' '$NEWNAME'"
|
|
fi
|
|
fi
|
|
done
|