Dave Horsfall <[EMAIL PROTECTED]> wrote:
> On Sat, 7 Apr 2001, 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
> > words I need to change the underscore "_" character to a dot "." for all the
> > file names in a directory. If there is a way to do this w/o a shell script
> > it would be great but I can't find one.
>
> Use the following script; it emulates the "=" wildcard of CP/M systems.
>
> Usage would be (in your case) "mved q=_tif.bz2 q=.tif.bz2".
>
> Use the "-n" switch for test only - no action. Hack for your shell
> where necessary.
cool, I'll have to digest that one and see if it ends up making it into
my list of scripts...
Anyway, what I usually do is the dumb:
me@mine> for i in q????_tif.bz2 ; do
> ni=`echo $i | sed 's/_tif.bz2//'` # set ni to the base part I want
> mv $i $ni.tif.bz2 # do the move
> done
That way I can season the action to taste, depending upon what exactly
I wanted to do. (Since you can get REALLY creative there when you
set $ni. Of course: (1) if you are not using bash then you'll have
to change things a bit; and (2) if you are not lucky enough to be
changing the destination name to something that has a '$'-eval
delimiter as its first char then you'll have to say something like:
mv $i "$ni"foo.boo.yoohoo
but, you knew that, right? ;-)
And, yes, I know the problem has now been solved at least 3 different
ways - isn't that (one of the) point(s) of unix? ;-)
rc
Rusty Carruth Email: [EMAIL PROTECTED] or [EMAIL PROTECTED]
Voice: (480) 345-3621 SnailMail: Schlumberger ATE
FAX: (480) 345-8793 7855 S. River Parkway, Suite 116
Ham: N7IKQ @ 146.82+,pl 162.2 Tempe, AZ 85284-1825
ICBM: 33 20' 44"N 111 53' 47"W