On Tuesday 12 Aug 2003 5:05 am, Todd Slater wrote:
> On Tue, Aug 12, 2003 at 12:41:05AM +0100, Richard Urwin wrote:
> > On Monday 11 Aug 2003 9:08 pm, Todd Slater wrote:
> > > On Mon, Aug 11, 2003 at 01:28:59PM -0500, fifner the dragon wrote:
> > > > Hi all,
> > > >
> > > > I just started to rip my complete cd collection to ogg using
> > > > Grip. The ogg files are named by default like:
> > > > "11_sun_in_your_face.ogg" The encode file format is set to
> > > > "~/mp3/%A/%d/%t_%n.ogg"
> > > >
> > > > I want capital letters in the beginning of every word and
> > > > spaces instead of underlines between the words.
> > > >
> > > > How shoud I set the encode file format to get the following
> > > > file name: "11_Sun In Your Face.ogg"
> > > >
> > > > Thanks in advance,
> > > >
> > > > Fifner
> > >
> > > This is Linux, you'll have to do that manually to each file you
> > > encode.
> > >
> > > Or, you can use another app like easytag.
> > >
> > > But seriously now folks,  there should be an option in options
> > > somewhere that says "replace spaces with underscores". I'd say if
> > > you uncheck that you should be set except for the capital
> > > letters. My first instinct is "man tr" on that one.
> >
> > tr only matches single characters, it could uppercase the whole
> > name,
>
> Like I always say, never trust your first instinct ;)
>
> > but it isn't up to capitalising each word. The required command is
> > something like:
> >   for $i in *.ogg do
> >     mv $i `echo $i|sed "s/\([_ ]\)\([a-z]\)/\1\u\2/g"`
> >   done
> > The sed command is correct, but I get syntax errors on the 'for',
> > maybe someone can jump in and correct me.
>
> If the filename has spaces in it you need to quote $i in the mv
> command, i.e. 'mv "$i" ...'.

True. but I couldn't get it to get that far. It complains that "mv" is 
unexpected. Something to do with the "for" syntax that I couldn't find 
the right mystical incantation for.

> If you're interested, here's a comp.unix.shell search on change case:
>
> http://groups.google.com/groups?hl=en&lr=&ie=ISO-8859-1&q=change+case
>&meta=group%3Dcomp.unix.shell
>
> There I found this script that works for converting to initial caps:
>
> #!/bin/sed -f
> s/$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/
> s/^\([a-z]\)\(.*\1\)\(.\)/\3\2\3/
>
> :more
>
>  s/\([  ]\)\([a-z]\)\(.*\2\)\(.\)/\1\4\3\4/
>  t more
>  s/aA[b-zB-Z]*$//
>

That is a general purpose script for handling text. In this case we can 
be simpler and still get the job done.

>  (the stuff in the first pair of brackets after :more is a space and
> a tab.)
> However, it will not work with a file named "11_fun in the sun.ogg"
> as "11_fun" counts as a word.

Add a _ to the space and tab and it would work.

> Todd

-- 
Richard Urwin

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to