Back in the day I used 'rip', a Perl script that handled things nicely and did exactly what I think you want it to do.

Take a look: http://rip.sourceforge.net/ - last updated in 2003 but it should still be pretty useful.
_________________________
Hussein