How to rebuild WordPress permalinks WordPress

So if I now have a few thousand posts (just imported from another blog), and I change the structure of the permalinks, and suddenly all the pages on the site give 404 errors, what is the easiest way to rebuild all the perma-links?