I need to combine directories as follows:

Source directory structure:

DirA
        SubDirAA
                More directories
        SubDirAB
                More directories
        SubDirAC
                More directories
DirB
        SubDirAA
                More directories
        SubDirAB
                More directories
        SubDirBC
                More directories


I want to copy these directories so that the target directory looks like
this:

Target directory structure

SubDirAA
        combined directories
SubDirAB
        combined directories
SubDirAC
        combined directories
SubDirBC
        combined directories

So the sub directories in DirA will be combined with like-named sub
directories in DirB and they will move up a level in the hierarchy.

I have the following script for combining txt files in a directory but I
don't know the Perl syntax well enough to apply it to combining directories
(if I can modify this script for that purpose).  I've done an extensive web
search but haven't found much that helps.  Can someone point me in the right
direction?

#!perl
use warnings;

for my $f ( map "lv$_.txt", 1..960)
{
        for ( grep -f, map $_.$f, qw( a/ b/ c/ d/ e/))
        {
                $f2 = $_;

                open STDIN, $_;
                open STDOUT, ">>$f";

                while( <STDIN> ) {
                        unless($_ =~ /username/ ) {
                                print STDOUT "$_";
                        }elsif ($f2 =~ /a/ ) {
                                print STDOUT "$_";
                        }
                }
        }
}

This is a great script that I believe I got from one of you listers.  It
takes the directories specified and combines all of the "like-named" lv.txt
files -- there are lv1 to lv960 files in each directory.  Any files after
the first directory get their header stripped out -- the header always
starts with "username."  Can this code be modified to combine directories?
Obviously I won't need the piece that strips out the headers. I'm using
windows directories.

Thanks,
Debbie



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to