Directory rename

Alex Janssen alex at ourwoods.org
Fri Nov 24 19:26:30 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.
>
> Output should look like: mv "junk2 test test" "Junk2 Test Test"
>
> Alex
>   
My apologies to those of you with plain text readers. Here's that script 
again in plain text.

# titlecase.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

 
Regards,
Alex

-- 
Ourwoods.org
Charlottesville, Virginia





More information about the ubuntu-users mailing list