----- Original Message ----- From: "bright true" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <beginners@perl.org>
Sent: Wednesday, May 11, 2005 2:55 PM
Subject: Re: rename files



The following would rename any file in a directory (.anything) into numbers

in the same extention i hope it will be usfull

opendir(DIR,"$dir") or print "$!";
my @content = sort(readdir(DIR));
closedir(DIR);
my $no=0;
*foreach my* $number (@content){
$no++;
$number =~m/\S+\.(\S+)/;
rename("$dir/$number","$dir/$no.$1");}

by the way , you forgot to mention the directory you want to rename file in


Exactly, Right. Thanks, Bright.


therefore you got this Error : can not rename file: No such file or
directory

rename("$dir/$file","$dir/$file");

bye

bye



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to