ChrisWilson - 6:35 pm on Nov 5, 2013 (gmt 0)
What had happened was, the site was hacked. The attacker altered the vbseo file part that controls how links were created and displayed. So a lot of my pages went 404 as I didn't notice the hack until three weeks after it happened.
Of course by then, Google had re-scanned the site, and there were new links to the same old pages and the old pages were now 404.
So for those, the old url structure was brought back, and all the new urls that had been created due to the hack were 301'd back to their original place, and by programmatically I mean that this was done with the script, not 301'ing one by one.
The other half of the 404's were actually 404, the site has some age to it and I let the 404 errors slide until there were quite a few. So for those, I just manually 301'd to a related thread that was better then the one that was deleted or missing.