CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Copying Folders

 



benchivers
Novice

Dec 10, 2002, 8:46 AM

Post #1 of 3 (545 views)
Copying Folders Can't Post

Hi,

I am trying to copy a folder from one location to another on my hard drive using Perl.

I wanted to use File::Copy module for doing this, only to find that the module doesn't support copying folders from one location to another.

Can someone please help me.

The folder which I am copying will also contain many different file types, and contain many sub-directories as well.

Any help would be most appreciated.

Many Regards,

Ben Chivers
Wheres the damn coffee? zzzZZZZZ!!!


Jasmine
Administrator

Dec 10, 2002, 9:24 AM

Post #2 of 3 (543 views)
Re: [benchivers] Copying Folders [In reply to] Can't Post

Perhaps [url=http://search.cpan.org/author/MZSANFORD/File-NCopy-0.33/lib/File/NCopy.pm]File::NCopy will work?

I haven't tried it, but the docs look like it'll do just what you need it to.


Code
    use File::NCopy qw(copy); 

copy "file","other_file";
copy "file1","file2","file3","directory";

# we want to copy the directory recursively
copy \1,"directory1","directory2";
copy \1,"file1","file2","directory1","file3","directory2","file4",
"directory";



Paul
Enthusiast

Dec 10, 2002, 3:29 PM

Post #3 of 3 (539 views)
Re: [benchivers] Copying Folders [In reply to] Can't Post


Quote
I wanted to use File::Copy module for doing this, only to find that the module doesn't support copying folders from one location to another.


You could use cp if you really wanted.

Code
system("cp -R /root /dev/null") == 0 or die "Phew, you got lucky: $!";


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives