1234567891011121314151617181920212223242526272829 |
- #!/bin/sh
- usage () {
- cat <<EOF>&2
- Usage: ${0##*/} FILES
- Rename FILES to lowercase if destination does not exist.
- EOF
- }
- [ $# -eq 0 ] && usage && exit 1
- [ "$1" = "-h" ] && usage && exit
- [ "$1" = "--" ] && shift
- for f ; do
- filename=${f##*/}
- case "$f" in
- */*) dirname="${f%/*}" ;;
- *) dirname="." ;;
- esac
- nf="$(echo "$filename" | awk '{print tolower($0)}')"
- [ "$nf" = "$filename" ] && continue
- newname="${dirname}/${nf}"
- mv -nv "$f" "$newname"
- done
|