Directory rename

Alex Janssen alex at ourwoods.org
Fri Nov 24 20:17:08 UTC 2006


Here's a version with some usage help:

# rename2titlecase.sh - rename files to Title Case - 11/24/2006 Alex P. 
Janssen Jr.
if [ $# = 0 ]
then
  echo -e "\
  usage: $0 filename ...
  Wild cards * and ? may be used if preceded with \ to escape shell 
expansion.
  Or, enclose your wild carded filenames in doublequotes \"fn*\""
fi

TMPFILE="/tmp/titlecase$$"
ls $@ >$TMPFILE
awk '{
  ORS="";
  x1=split($0,a1);
  print("mv \"" $0 "\" \"");
  for (SX in a1) {
    print(toupper(substr(a1[SX],1,1)) tolower(substr(a1[SX],2)) );
    if(--x1>0)
      print(" ")
    }
  print("\"\n")
  }' $TMPFILE
rm -f $TMPFILE
exit 0


That's All Folks!

Alex

-- 
Ourwoods.org
Charlottesville, Virginia





More information about the ubuntu-users mailing list