Gossamer Forum
Home : General : Perl Programming :

Copy files to other directory

Quote Reply
Copy files to other directory
Please help me to copy all .gif files from one directory to other one with by using perl.


Quote Reply
Re: Copy files to other directory In reply to
perldoc File::Copy
perldoc -f unlink

-g


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';
Quote Reply
Re: Copy files to other directory In reply to
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/

Quote Reply
Re: Copy files to other directory In reply to
10x Paul

Quote Reply
Re: Copy files to other directory In reply to
10x?

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: Copy files to other directory In reply to
Think that was meant to be ten star...lol Wink

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Copy files to other directory In reply to
Actually I think it means 'thanks'.

tenx = thanks

My guess at any rate.


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: Copy files to other directory In reply to
Ahhhh Smile

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/