Date: Tue, 27 Nov 2001 03:47:39 -0500 From: parv <parv_@yahoo.com> To: jayyness@mindspring.com Cc: freebsd-questions@freebsd.org Subject: Re: Mass Renaming of Files Message-ID: <20011127034739.A42224@moo.holy.cow> In-Reply-To: <20011127030749.A38784@moo.holy.cow>; from parv_@yahoo.com on Tue, Nov 27, 2001 at 03:07:49AM -0500 References: <Springmail.105.1006808059.0.84387100@www.springmail.com> <20011127030749.A38784@moo.holy.cow>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011127034739.A42224>
