From owner-freebsd-questions Tue Nov 27 0:46:26 2001 Delivered-To: freebsd-questions@freebsd.org Received: from avocet.prod.itd.earthlink.net (avocet.mail.pas.earthlink.net [207.217.120.50]) by hub.freebsd.org (Postfix) with ESMTP id 84F4837B6B2 for ; Tue, 27 Nov 2001 00:46:01 -0800 (PST) Received: from sdn-ar-007dcwashp294.dialsprint.net ([63.178.90.160] helo=moo.holy.cow) by avocet.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 168dsJ-00006J-00; Tue, 27 Nov 2001 00:45:55 -0800 Received: by moo.holy.cow (Postfix, from userid 1001) id 7266250CEF; Tue, 27 Nov 2001 03:47:39 -0500 (EST) Date: Tue, 27 Nov 2001 03:47:39 -0500 From: parv To: jayyness@mindspring.com Cc: freebsd-questions@freebsd.org Subject: Re: Mass Renaming of Files Message-ID: <20011127034739.A42224@moo.holy.cow> Mail-Followup-To: jayyness@mindspring.com, freebsd-questions@freebsd.org References: <20011127030749.A38784@moo.holy.cow> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20011127030749.A38784@moo.holy.cow>; from parv_@yahoo.com on Tue, Nov 27, 2001 at 03:07:49AM -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG in message <20011127030749.A38784@moo.holy.cow>, wrote parv thusly... > ... > beware of a bug: this doesn't check if you there is already another > file w/ the same name as the translated one. ... well, given competition, i updated my program to check for duplicates. complete program is here... http://www103.pair.com/parv/comp/unix/bin/sanefilename.perl ...and the patch is... --- bin/sanefilename.perl.old Tue Nov 27 03:34:07 2001 +++ bin/sanefilename.perl Tue Nov 27 03:43:38 2001 @@ -1,7 +1,7 @@ #! /usr/local/bin/perl -w ## author: parv, parv_@yahoo.com -## date: aug 31 2001 +## date: nov 27 2001 ## ## license: free to use as you please w/ credit given ## @@ -13,7 +13,7 @@ ## ## usage: ## sanefilename.perl [-low] file [file2 file3 ...] -## (-low option excludes [A-Z] characters]) +## (-low option excludes [A-Z] characters) use strict; @@ -88,10 +88,18 @@ } #else #{ - print " - ${path}${old_file} -> ${path}${new_file} ... \n"; - - move("${path}${old_file}","${path}${new_file}") - || die "\* couldn't move ${path}${old_file} to ${path}${new_file}: $! \n" ; + if ( -e $path . $new_file ) + { + print " \* ${path}${new_file} already exists, skipping ${path}${old_file} ...\n"; + next; + } + #else + #{ + print " - ${path}${old_file} -> ${path}${new_file} ... \n"; + + move("${path}${old_file}","${path}${new_file}") + || die "\* couldn't move ${path}${old_file} to ${path}${new_file}: $! \n" ; + #} #} #} } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message