The most practical method I have yet found to efficiently fill my Blu-Ray disks.
I make a list of fully qualified paths to all of the available files to burn.
Then (arbitrarily) decide on how many directory levels to consider a bunch or accept a command line option for it. This is to keep directories full of like items all together on a single blu-ray. There is also a STUFF option to insert the largest files first and when a file would cause an overflow, look to the next smaller one until you run out of files or space.
Make a hash with each directory as key and total size of the files it contains as the data. Also keep a parallel hash with the count of files per directory as slack space and directory overhead apparently add up and have to be accounted for.
Pick 22 as the magic number. If you have <= 22 directories, try all combinations to find
the one closest to but not over 25.025 GB. If you have more than 22, just use the 22 largest. I use the Perl module Algorithm::Combinatorics to find all of the combinations. Through trial and mostly error, I determined that combinations of 21 items takes just a few seconds. 23 items takes many minutes which is longer than my attention span. 22 takes about 35 seconds.
An output directory is also accepted and checked for existing data. There is an option to move the files (copy, check size and unlink).
Every time I bought a new hard drive, it was usually twice as large as the previous one so I would just copy everything over. With a Nikon D800E (Extreme!), HDR and Panoramas, I finally ran out of space.
My project was to unique, weed and consolidate 15 years worth of [mostly junk] photos, videos, movies, music, etc. I inventoried roughly a dozen storage devices, calculated MD5 signatures and put them all in a database. I picked one drive as master for pics and one for video and nuked everything else. I found 8 copies of some stuff!
I now have about 10 TB of free disk space!!!
Below the function which does all of the real work in case anybody is interested.
===============================================
Oops! Your answer couldn't be submitted because:
Your post appears to contain code that is not properly formatted as code
The stupid web page mangled my pristine code. Sorry :(..