Hi,

given n directories D1..Dn with arbitrary content. I would like a function that takes these source directories and copies their contents to a destination directory Dd such, that Dd is the union of all files and the fs structure of D1..Dn.

D1
 - Folder1
   - file1
   - file2
 - Folder2
   - file4

D2
 - Folder1
   - file3
   - file5
 - Folder3
   - file7

=>

Dd
 - Folder1
   - file1
   - file2
   - file3
   - file5
 - Folder2
   - file4
 - Folder3
   - file7

Right now, I can assume, that the sets of D1..Dn are mutually exclusive, but of course a hook on how to behave on clashes (and what type of clash .. name/diff) would not hurt.

Does such a thing already exist? I know about UnionFS, but rather than this transparent solution I would prefer a CLI-based batch processing tool, because these merging operations are one-shot only.

Update:

Maybe I should start to have LESS Perl on my mind... ;-)

> cp -a D[12]/* Dd/

Does the trick. Ok, it's not that portable, it's not perl, but for the moment...

Bye
 PetaMem
    All Perl:   MT, NLP, NLU


In reply to Unification of Directories (their contents) by PetaMem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.