in reply to how to find the free amount of space in rw - cd/dvd

I'd just parse the 4th column of df -h <mountpoint>. About the decision of wether to write or not to the DVD, if the problem is optimizing so that you waste as little space as possible then it's possible that the problem falls into the Knapsack category.