Split file/folder structure to make iso CD
vnpenguin
created: 2006-04-04 10:57:58
Hi all, I have a data about 2G with many of files and sub-folders (/tmp/MyDir). I would like to make 3 or 4 iso CD from them with a condition: a sub-folder can not be splitted into 2 CD. Is there a Perl script to do that automatically ? I mean that this script allows me to create :
/tmp/cd1
/tmp/cd2
/tmp/cd3
/tmp/cd4
from /tmp/MyDir. So I could run mkisofs later to make iso. I already done a search on perlmonks site, but no solution. Thanks,
Re: Split file/folder structure to make iso CD
created: 2006-04-04 11:03:13
It is, imho, more bashish than perlish question :>)
I recommend to tar it and split it, if you have a lot of disk space...
Re: Split file/folder structure to make iso CD
created: 2006-04-04 11:23:54
vnpenguin,

Perhaps the discussion in How to maximise the content of my would be of interest to you. Super Search is your friend :)

Hope this helps.

Martin
Re: Split file/folder structure to make iso CD
created: 2006-04-04 15:43:28

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.

perlmonks.org content © perlmonks.org and marto, pajout, Tanktalus, vnpenguin

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03