From owner-freebsd-questions@FreeBSD.ORG Sat Jan 5 08:08:46 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7FC5516A46B for ; Sat, 5 Jan 2008 08:08:46 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 4151813C461 for ; Sat, 5 Jan 2008 08:08:45 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.2/8.14.2) id m0588jph032663; Sat, 5 Jan 2008 02:08:45 -0600 (CST) (envelope-from dan) Date: Sat, 5 Jan 2008 02:08:45 -0600 From: Dan Nelson To: Jeff Laine Message-ID: <20080105080845.GG52545@dan.emsphone.com> References: <2b98f2f70801042134x1af4f721s877677afde7151f5@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b98f2f70801042134x1af4f721s877677afde7151f5@mail.gmail.com> X-OS: FreeBSD 7.0-PRERELEASE User-Agent: Mutt/1.5.17 (2007-11-01) Cc: freebsd-questions@freebsd.org Subject: Re: batch rename X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jan 2008 08:08:46 -0000 In the last episode (Jan 05), Jeff Laine said: > My goal is to rename several files in such a way as to decapitalize > starting letters in their names. The solution seems to be simple but > I'm stuck. What should I use? awk/sed or write some shell-script? Best way is with ports/misc/mmv: mmv "?*" "=l1=2" If you use zsh, you can use the zmv function to do the same thing: autoload -U zmv zmv '([A-Z])(*)' '${(L)1}$2' Both of the above will detect filename collisions and tell you what won't work. If you know there aren't any collisions, you could do this (zsh again): for i in [A-Z]* ; do mv $i ${i[1]:l}${i[2,-1]} done -- Dan Nelson dnelson@allantgroup.com