I do exactly the same thing, using proprietary code (sorry, can't share it). However, I use some key non-proprietary code which I can point you to: Filesys::DiskUsage to determine the size of a directory. Note that sector sizes on CDs are generally 1024 bytes, which doesn't match what du will tell you, but Filesys::DiskUsage can take parameters that allow you to specify what blocksize to assume.

For my case, I need directories to show up on the CD in a particular order, which means that if dir5 can fit on disk1, but dir4 can't, then I can't put dir5 on disk1 in dir4's place. That may not be true for you. For me, it means that I may use more CDs, but I avoid the knapsack problem. You may need to look that problem up if you want to minimise the number of CDs that you need.

If you are minimising, all you need to do is use Filesys::DiskUsage to get the sizes of each directory, then you can sort the directories in memory using those numbers until you get your solution. Then you can copy the directories around - I often use tar for copying directory structures which makes things much easier when you're dealing with many files, especially if some are symlinks and the like.


In reply to Re: Split file/folder structure to make iso CD by Tanktalus
in thread Split file/folder structure to make iso CD by vnpenguin

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.