Not only do you have to consider the file sizes but the file names could be long and cause a directory table to extend. So while you can google "BURN TO THE BRIM BURNER" there's a reason it's not usually used. The inexactness of the target file system and more.
https://sourceforge.net/p/bttb/discussion/164745/thread/894fcd96/?page=1 is a typical back and forth about this app.
I was wondering if there was software that could show, from a set of data files of varying size, what assortment of which files would come closest to a certain total number. Say I've determined that my dvds will hold no more that 4.687 GB of data. And say I have a folder with a dozen or so files of varying size. Rather than guessing and adding/subtracting files back and forth to try to come closest to 4.687 gb without going over, if there was a program to tell me which combination(s) of files (identifying each file by it's size) would save so much time. Hope I've explained this correctly. Haven't found anything in numerous online searches yet.