From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Alok K. Dhir" Subject: Re: Stupid spaces Date: Thu, 12 Feb 2004 16:23:16 -0500 Sender: linux-admin-owner@vger.kernel.org Message-ID: <402BEEC4.8080605@symplicity.com> References: <5.2.1.1.0.20040212130333.00b0f4a0@mustang> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040905060209030008010102" Return-path: In-Reply-To: <5.2.1.1.0.20040212130333.00b0f4a0@mustang> List-Id: To: Scott Taylor Cc: linux-admin@vger.kernel.org This is a multi-part message in MIME format. --------------040905060209030008010102 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. Al Scott Taylor wrote: > Hello all, > > I've done this before, but so long ago I can't find it again. I have > a bunch of files with spaces in them and I want to rename them with > the spaces removed. > > I have a rename command that came with RH7.2 but doesn't do the job > rename 's/\ //g' * > does nothing in bash > > So I wrote a script many moons ago to do this but I can't remember > which server it was on, let alone how I did it. Something with tr and > mv methinks. > > anyone? > > - > To unsubscribe from this list: send the line "unsubscribe linux-admin" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- Alok K. Dhir Symplicity Corporation http://solutions.symplicity.com 703 351 6987 (w) | 703 351-6357 (f) --------------040905060209030008010102 Content-Type: text/plain; name="rename.pl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="rename.pl" #!/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); } --------------040905060209030008010102--