Directory rename

Alex Janssen alex at ourwoods.org
Fri Nov 24 18:10:02 UTC 2006


Alex Janssen said the following on 11/24/2006 12:44 PM:
> When you paste this script,  make sure there are no line breaks in the 
> awk command between the single quotes.
>
>   
Ralph,

Here's a better formatted copy with a more relevant name:

# rename2titlecase.sh - rename files to Title Case - 11/24/2006 Alex P. 
Janssen Jr.
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

I was wrong about the line breaks in the awk command.  You can paste 
this into a script file as-is.
It's been a good learning opportunity.
HTH,
Alex

-- 
Ourwoods.org
Charlottesville, Virginia





More information about the ubuntu-users mailing list