[GRLUG] Shell script needed
Marc Zuverink
mzuverink at gmail.com
Tue Jul 3 17:41:32 EDT 2007
john-thomas richards wrote:
> On Tue, Jul 03, 2007 at 03:08:00PM -0400, Marc Zuverink wrote:
>
>> I am looking for a shell script to run on my /music. It needs to
>> replace all capital letters in all sub dirs of /music and replacing
>> capital letters with lowercase replace all spaces with underscore in
>> both the sub dirs and the enclosed files.
>>
>> Help with this would really be appreciated!
>>
>
> Something like this?
>
> #! /bin/sh
>
> for filename in * # Traverse all files in directory.
> do
> fname=`basename $filename`
> n=`echo $fname | tr A-Z a-z` # Change name to lowercase.
> if [ "$fname" != "$n" ] # Rename only files not already
> # lowercase.
> then
> mv $fname $n
> fi
> done
>
>
That worked just fine, thank you!
--
Marc Zuverink <mzuverink at gmail.com>
I hate to advocate drugs, alcohol, violence, or insanity to anyone, but they've always worked for me.
-Hunter S. Thompson
More information about the grlug
mailing list