From owner-freebsd-questions@FreeBSD.ORG Mon Jan 26 06:48:40 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 20C9016A4CE for ; Mon, 26 Jan 2004 06:48:40 -0800 (PST) Received: from fw.farid-hajji.net (fw.farid-hajji.net [213.146.115.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id E051743D3F for ; Mon, 26 Jan 2004 06:48:36 -0800 (PST) (envelope-from cpghost@cordula.ws) Received: from fw.farid-hajji.net (localhost [127.0.0.1]) by fw.farid-hajji.net (Postfix) with ESMTP id 56F0740824; Mon, 26 Jan 2004 15:47:58 +0100 (CET) From: Cordula's Web To: a.kotsopoulos@tue.nl In-reply-to: <4014F3FB.1030204@tue.nl> (message from Andrew Kotsopoulos on Mon, 26 Jan 2004 12:03:23 +0100) X-Mailer: Emacs-21.3.1/FreeBSD-4.9-STABLE References: <4014F3FB.1030204@tue.nl> Message-Id: <20040126144758.56F0740824@fw.farid-hajji.net> Date: Mon, 26 Jan 2004 15:47:58 +0100 (CET) cc: freebsd-questions@FreeBSD.ORG Subject: Re: "rename" shell command X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: cpghost@cordula.ws List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jan 2004 14:48:40 -0000 > I'm looking for the "rename" shell command for the macosx version of > bsd. In redhat and possibly other linux distributions the command > renames files and supports wildcards and multiple file conversions, as > you most likely know. To be more precise here is the man page: Here's a script in perl. Use like this: ### Append .bak to all *.c files $ rename '$_ .= ".bak"' *.c ### Remove .bak from all *.c.bak files $ rename 's/\.bak$//' *.c.bak ### Convert to lowercase, but not for Makefile $ rename 'tr/A-Z/a-z/ unless /^Makefile/' * #!/usr/bin/perl -w # rename -- Larry's filename fixer $op = shift or die "Usage: rename expr [files]\n"; chomp(@ARGV = ) unless @ARGV; for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; } -- Cordula's Web. http://www.cordula.ws/