I appreciate the help, is there a way to do it by taking the source and
target directory's as command line arguments?  that is how the unix script
is written that I am trying to convert.

Thanks.

----- Original Message ----- From: "Chris Charley" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Wednesday, April 20, 2005 3:14 PM
Subject: Re: Copy and rename files



A correction to the code for 1 line below  :-(
Chris

Hello Brian,

I did what you wanted to do on my computer, (Windows XP). The code is pasted below, followed by some explanations. You should be able to get the same results by plugging in abc and xyz where I had html and txt. Also, with source and target directories of your choosing.

#!/usr/bin/perl
use strict;         use warnings;
use File::Copy;

my $source = "/Run";
my $target = "/temp";
my $filecount;

opendir DH, $source or die "Unable to open directory $source: $!;
for (readdir DH) {
   next unless /html?$/ && -s;

next unless /html?$/ && -s "$source/$_";

   print "The fileneme is $_\n";
   (my $txt = $_) =~ s/html?$/txt/;  copy("$source/$_", "$target/$txt");
   $filecount++;
}
close DH;

print "$filecount files copied\n";





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



--
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