From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Taylor Subject: Re: Stupid spaces Date: Thu, 12 Feb 2004 14:19:43 -0800 Sender: linux-admin-owner@vger.kernel.org Message-ID: <5.2.1.1.0.20040212141846.00aa13e8@mustang> References: <5.2.1.1.0.20040212130333.00b0f4a0@mustang> <5.2.1.1.0.20040212130333.00b0f4a0@mustang> <402BEEC4.8080605@symplicity.com> Mime-Version: 1.0 Return-path: In-Reply-To: <402BEEC4.8080605@symplicity.com> References: <5.2.1.1.0.20040212130333.00b0f4a0@mustang> <5.2.1.1.0.20040212130333.00b0f4a0@mustang> List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" Content-Transfer-Encoding: 7bit To: linux-admin@vger.kernel.org At 01:23 PM 02/12/2004, Alok K. Dhir wrote: >The attached rename.pl is invaluable for such tasks. > >Use it exactly like your bash rename attempt. You can use pretty much any >perl in-place-modifier construct - s/X/Y/, tr/A-Z/a-z/ (upper->lower), etc. > >Not sure where I found this originally, but it's extremely handy. > > >#!/usr/bin/perl > >if (@ARGV == 0) { > die "usage: rename PATTERN FILESPEC\n"; >} > >$pattern=shift; > >foreach (@ARGV) { > my $oldname=$_; > my $newname=$_; > eval ("\$newname=~$pattern"); > rename($oldname, $newname); >} Very. Thanks. Not a BASH script, but works great. Thanks.