Try checking out CGMonks and their CGMToolbox. In the TDTools section there is a script that will do exactly what you are saying. Best of luck.