Directory rename

Alex Janssen alex at ourwoods.org
Fri Nov 24 17:44:10 UTC 2006


Ralph Thaller said the following on 11/24/2006 03:50 AM:
>
>
>
> mhm thx for this script!
> But i get a a wrong output:
> i have a structur looks like this:
> pc  pc__8_3
>
> when i run your script in this director i only get this:
> mv pc P
> mv pc__8_3 P
>
> Ralph
>
>
>
>
Ralph,

Try this new version:

# 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

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

-- 
Ourwoods.org
Charlottesville, Virginia





More information about the ubuntu-users mailing list