Please help me to copy all .gif files from one directory to other one with by using perl.
May 9, 2001, 7:40 AM
Veteran (19537 posts)
May 9, 2001, 7:40 AM
Post #3 of 8
Views: 5540
Try
use File::Copy;
my $path = "/path/to/images";
my $newpath = "/path/to/newimg";
opendir(DIR, $path) || die "Can't open dir : $!";
@files = grep {/\.gif$/}, readdir(DIR);
close(DIR);
foreach (@files) {
&File::Copy::copy ("$path/$_", "$newpath/$_") or die "Unable to copy. Reason: $!");
}
That should work although I haven't tested it so I may have the syntax slightly wrong.
Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/
use File::Copy;
my $path = "/path/to/images";
my $newpath = "/path/to/newimg";
opendir(DIR, $path) || die "Can't open dir : $!";
@files = grep {/\.gif$/}, readdir(DIR);
close(DIR);
foreach (@files) {
&File::Copy::copy ("$path/$_", "$newpath/$_") or die "Unable to copy. Reason: $!");
}
That should work although I haven't tested it so I may have the syntax slightly wrong.
Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/
May 31, 2001, 5:08 AM
Veteran / Moderator (18441 posts)
May 31, 2001, 5:08 AM
Post #6 of 8
Views: 5501
Think that was meant to be ten star...lol
Andy
webmaster@ace-installer.com
http://www.ace-installer.com
Andy
webmaster@ace-installer.com
http://www.ace-installer.com