ambevar-dotfiles/.scripts/renamelowerrec

26 lines
508 B
Bash
Executable File

#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} FOLDERS
Rename to lowercase all files found in FOLDERS if destination does not exists.
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
if ! command -v renamelower >/dev/null 2>&1; then
echo >&2 "'renamelower' not found"
exit 1
fi
## Note: the -name check is not mandatory, but greatly improves the average
## performance.
for i ; do
find "$i" -depth -name '*[[:upper:]]*' -exec renamelower {} +
done