in reply to My brain hurts! Recursive directory algorithm..
It doesn't have your "keep things together" constraint it looks like, but you might be able to adapt it for your needs. -- Mike