From owner-freebsd-questions Tue Jan 9 13:16:13 2001 Delivered-To: freebsd-questions@freebsd.org Received: from bcfw1d.bridge.com (bcfw1d.ext.bridge.com [167.76.159.31]) by hub.freebsd.org (Postfix) with ESMTP id 7043537B69B for ; Tue, 9 Jan 2001 13:15:54 -0800 (PST) Received: (from uucp@localhost) by bcfw1d.bridge.com (8.10.2/8.10.2) id f09LGiY21400; Tue, 9 Jan 2001 15:16:44 -0600 (CST) Received: from unknown(167.76.56.34) by bcfw1d.bridge.com via smap (V5.5) id xma021360; Tue, 9 Jan 01 15:16:37 -0600 Received: from mnmailhost (mnmailhost.bridge.com [167.76.155.14]) by mail1srv.bridge.com (8.8.8/8.7.3) with SMTP id PAA26323; Tue, 9 Jan 2001 15:15:36 -0600 (CST) Received: from 89-7 by mnmailhost (SMI-8.6/SMI-4.1) id QAA14033; Tue, 9 Jan 2001 16:15:32 -0500 To: Subject: Re: A simple shell question, How do i rename multiple files? References: <003101c07a95$b24117a0$46010a0a@sysadmininc.com> From: Tim Ayers Date: 09 Jan 2001 15:15:32 -0600 In-Reply-To: "Peter Brezny"'s message of "Tue, 9 Jan 2001 15:41:31 -0800" Message-ID: Lines: 18 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >>>>> "P" == Peter Brezny writes: P> I've got a bunch of files all ending in the same extension (somename.xxx) P> I want to rename all of them to just (somename) P> I've tried P> mv *.xxx * This is a surprisingly hard thing to do in UNIX. I don't think there's a way to do it with 'mv'. Here's how to do it with a Perl one-liner . !!!Be sure to change the 'xxx' _in both places_ to whatever your extension is!!! perl -e'for (@ARGV) {($a)=/(.*)\.xxx/; rename $_, $a or die $!}' *.xxx HTH, Tim Ayers (tayers@bridge.com) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message