Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Copy folders

by avik1612
on Aug 28, 2007 at 06:22 UTC ( #635503=perlquestion: print w/ replies, xml ) Need Help??
avik1612 has asked for the wisdom of the Perl Monks concerning the following question:

How to copy folder from onr location to another i tried using File::Copy but it is not working Thanks in advance Avi

Comment on Copy folders
Re: Copy folders
by moritz (Cardinal) on Aug 28, 2007 at 06:59 UTC
Re: Copy folders
by andreas1234567 (Vicar) on Aug 28, 2007 at 07:14 UTC
    File::Copy's copy function copies files, not directories. You can use File::Find to find the files and use those as input to File::Copy.
    use strict; use warnings; use File::Copy; use File::Find; my @fromdirs = qw (/tmp/foo); my $todir = q{/tmp/bar}; find( sub { if (-f) { print "$File::Find::name -> $todir"; copy($File::Find::name, $todir) or die(q{copy failed:} . $!); } }, @fromdirs ); __END__ $ mkdir -p /tmp/foo $ mkdir -p /tmp/bar $ touch /tmp/foo/1 $ touch /tmp/foo/2 $ perl -l 635503.pl /tmp/foo/1 -> /tmp/bar /tmp/foo/2 -> /tmp/bar
    --
    Andreas
Re: Copy folders
by Samy_rio (Vicar) on Aug 28, 2007 at 07:21 UTC

    Hi avik1612, copy the folder using File::Copy::Recursive

    use strict; use warnings; use File::Copy::Recursive qw(dircopy); dircopy('E:\test\split\Output','C:\New') or die("$!\n");

    Regards,
    Velusamy R.


    eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://635503]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-08-21 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls