On Thu, Jan 17, 2002 at 05:42:31PM -0000, John wrote:
> -- code --
> my ($name, $ext) = split(/\./,$fileoutname);
> 
>     if ($name =~ /\((\d{1,1})\)$/) { # Looks for (1) on the end for example
>         my $number = $1;
>         $number++;
>         $name =~ tr/\(\d\)/\($number\)/;
>     } else {
>         $name .= "(1)";
> }
> 
> $fileoutname = "$name\.$ext";

> my ($name, $ext) = split(/\./,$fileoutname);

Is this on windows? Or could you have name.some.more.ext?


my $num= ($name=~/\((\d+\)/)?$1:1;
$num++ while(-e "$name($num).$ext");
        

Is a bit more robust as it checks the directory and loops till it
doesn't find a match for the file. IMO FWIW ;)

-- 
 Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to