Source

css / bin-cs / lc

#!/bin/sh
#
# Lowercase a bunch of pathnames.
#	- Cameron Simpson <cs@zip.com.au>
#

rnopts=
while :
do
  case $1 in
    --)		shift; break ;;
    -?*)	rnopts="$rnopts $1" ;;
    *)		break ;;
  esac
  shift
done

set -x
exec frename $rnopts -- \
	'if (m:[^/]+$:)
	 { $lhs=$`;
           $_=$&;
	   s/\%([0-9a-f][0-9a-f])/chr(hex($1))/ieg;
	   tr/_&A-Z/-+a-z/;
	   s/[-\s]+/-/g;
	   s/^-/_/;
	   $_=$lhs.$rhs;
	 }
	' ${1+"$@"}