After moving my email account to Google Apps, I was looking for a way to migrate all of my old email in the Apple Mail.app to Google’s servers. In their setup guide, they link to the Google Email Uploader For Mac 1.2 app which seemingly is exactly what you want.
After giving it a go, it appears since OS X 10.7, Apple have changed the way they cache their email and there’s sub-folders (used for indexing?) numbered 1 to 9 (and occasionally ‘Data’) within each IMAP .mbox folder.
Since I’ve recently become a good Objective-C coder (mostly on iOS) I decided to check out the code from googles website and try to modify it to give proper labels for each individual mailbox.
I’ve uploaded my code to github and have a copy of the app here: