rbi has asked for the wisdom of the Perl Monks concerning the following question:
that I want to copy under directory destination. They contain both directories and files.origin dir1 subdir1 subdir2 subdir3 file1 file2 dir2 subdir1 subdir2 subdir3 file1 file2
Thank you in advance.use strict; use File::Copy; use File::Basename; use File::Path; use File::Glob ':glob'; my $din = 'c:/temp/origin/'; my $dout = 'c:/temp/destination/'; docp($din,$dout,1); sub docp { my $din = shift(); # ORIGIN DIRECTORY my $dout = shift(); # DESTINATION DIRECTORY my $tree = shift(); # DEPTH OF DIRECTORY RECURSION my ($f,$d,$b); die if -e $dout; mkpath($dout); my @list = bsd_glob($din."*"); map { ($f,$d) = fileparse($_); if (-d and $tree) { $f = $f.'/'; $b = $_.'/'; docp($b,$dout.$f,$tree) if $tree ge 0; } else { copy ($_,$dout.$f); } } @list; $tree = $tree - 1; }
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Replication of directory subtrees
by merlyn (Sage) on Apr 24, 2003 at 14:30 UTC | |
Re: Replication of directory subtrees
by Abigail-II (Bishop) on Apr 24, 2003 at 14:29 UTC | |
by Fletch (Bishop) on Apr 24, 2003 at 14:52 UTC | |
by Abigail-II (Bishop) on Apr 24, 2003 at 14:59 UTC | |
Re: Replication of directory subtrees
by eduardo (Curate) on Apr 24, 2003 at 14:52 UTC | |
by rbi (Monk) on Apr 24, 2003 at 15:05 UTC | |
by eduardo (Curate) on Apr 24, 2003 at 15:17 UTC |