Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Sep 1996 21:52:36 -0500 (CDT)
From:      dnelson@emsphone.com (Dan Nelson)
To:        ejs@bfd.com (Eric J. Schwertfeger)
Cc:        hmmm@alaska.net, questions@FreeBSD.org
Subject:   Re: multiple files
Message-ID:  <199609250252.VAA19516@dan.emsphone.com>
In-Reply-To: <Pine.BSF.3.95.960924163449.19000A-100000@harlie> from "Eric J. Schwertfeger" at Sep 24, 96 04:39:18 pm

next in thread | previous in thread | raw e-mail | index | archive | help
in the last episode, Eric J. Schwertfeger said:
> On Tue, 24 Sep 1996, hmmm wrote:
> > how can i rename multiple files w/o doing it 1-by-1?
> > ie,
> > 
> > abc.tar.gz > abc.tgz
> > def.tar.gz > def.tgz
> > hij.tar.gz > hij.tgz
> 
> Sounds like a job for perl.  But that's too easy so here's a demented way
> do do it in shell script (sh) (assuming there are no other periods in the
> file names).
> 
> for i in *.tar.gz; do
> 	mv $i $(echo $i | cut -f 1 -d . ).tgz
> done

Much as I like the Unix idea of multiple small programs doing a larger
task, this is ugly. :)

Check out /usr/ports/misc/mmv.  It'll do what you want: 
mmv "*.tar.gz" "=1.tgz"

	-Dan Nelson
	dnelson@emsphone.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199609250252.VAA19516>