From owner-freebsd-questions Tue Sep 24 19:52:52 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id TAA17335 for questions-outgoing; Tue, 24 Sep 1996 19:52:52 -0700 (PDT) Received: from dan.emsphone.com (-@dan.emsphone.com [199.67.51.101]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id TAA17311 for ; Tue, 24 Sep 1996 19:52:48 -0700 (PDT) Received: (from dan@localhost) by dan.emsphone.com (8.7.5/8.7.3) id VAA19516; Tue, 24 Sep 1996 21:52:36 -0500 (CDT) Message-Id: <199609250252.VAA19516@dan.emsphone.com> Subject: Re: multiple files To: ejs@bfd.com (Eric J. Schwertfeger) Date: Tue, 24 Sep 1996 21:52:36 -0500 (CDT) Cc: hmmm@alaska.net, questions@FreeBSD.org In-Reply-To: from "Eric J. Schwertfeger" at Sep 24, 96 04:39:18 pm From: dnelson@emsphone.com (Dan Nelson) X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-questions@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk 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