> On Sat, Apr 07, 2001 at 13:45 -0600, Dan Woods wrote:
> >
> > Kelley Terry wrote:
> > >
> > > Is there a way to rename multiple files all of the format
> > > q####_tif.bz2 to q####.tif.bz2 where the # represent digits. In other
> > ----------
> >
> > For your needs, you would want something like...
> > for NAME in `find www_root -name "q*tif.bz2" -type f` ; do
> > mv $NAME `echo $NAME | tr '_' '.'
> > done
> >
> > Only problem might be that *all* underscores will get changed.
>
> so would it work with
> mv $NAME 'echo $NAME | tr '_tif' '.tif'
> or not?
No, you're missing an end-quote, plus you're using the same quotes.
You need to use backquotes so that the echo returns a value.
mv $NAME `echo $NAME | tr '_tif' '.tif'`
However this won't do what you want since 'tr' translates each character
in the order listed. So '_' -> '.', all 't' -> 't', etc.
OK, so technically this would work, but not the way you would want.
Effectively
mv $NAME `echo $NAME | tr '_' '.'`
is the same thing as yours, except that *all* '_' are changed to '.'
Thanks... Dan.