On Mon, 2003-10-13 at 01:53, Jack Coates wrote:
> On Sun, 2003-10-12 at 06:27, Brian Parish wrote:
> > On Thu, 2003-10-09 at 15:44, HaywireMac wrote:
> > > On Sat, 04 Oct 2003 23:36:28 -0700
> > > Jack Coates <[EMAIL PROTECTED]> uttered:
> > >
> > > > hell, this is a one-liner :-)
> > > >
> > > > for i in `ls *.wav`; do lame -buncha -options $i; done
> > >
> > > alias that sucker in your .bashrc like this:
> > >
> > > function mp3enc() { for i in `ls *.wav`; do lame -buncha -options $i;
> > > done }
> > >
> > > and in reverse:
> > >
> > > function mp3dec() { for i in *.mp3; do lame --decode $i `basename $i
> > > .mp3`.wav; done; }
> > >
> > > the only problem you might run into is if the filenames have spaces, so,
> > > do this first:
> > >
> > > for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`;done;
> >
> > Being a total newb when it comes to shell programing, I found this to be
> > a great tip (having just spent considerable time writing a much longer
> > script to do the same thing *).
> >
> > Is there an equally simple way to truncate file names to remove unwanted
> > characters from the end? I of course would never dream of downloading
> > anything using gnutella, but should someone else do this and end up with
> > lots of files ending in ".OK", it would be nice to process them in a
> > similar way. Just theoretically of course.
> >
> > TIA
> > Brian
> >
> > * It didn't work either!
> >
>
> Try giving tr nothing as a second option, or use sed (challenging,
> better get an O'Reilly book).
>
> Here's one that might help as an example:
> [EMAIL PROTECTED] jack]$ cat bin/2lower.sh
> #!/bin/sh
> for i in *
> do
> j=`echo $i | tr '[A-Z]' '[a-z]'`
> mv $i $j
> done
>
> It comes in handy when installing Quake 2 maps that were built on
> Winders :-)
No, tried that. tr '.OK' '' complains that the second string cannot be
null and says to use the -t qualifier when truncating.
for i in *.OK; do mv "$i" `echo $i | tr -d '.OK'`;done;
removes the .OK just fine, but also removes ".", "O" and "K" wherever
they occur.
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com