How to sort new folders alphabetically in OS X Mail?
I am running Mac OS Sierra on a late 2009 iMac 27".  My Mac iCloud account mailboxes were NOT in alphabetical order and I have too many to manually sort.  Disabling and enabling IMAP Mail for my Mac iCloud account did not work for me. This did the trick perfectly.


Stop Mac application
Run these commands at a command line prompt in bash or ksh.  (Substitute your user name where you see "steve" below.  Substitute whatever you like for "Nov-12-2016".  That is just arbitrary stuff to rename the files and to be able to find them if needed later):



cd /Users/steve/library/Mail/V4

for file in $(find . -name .mboxCache.plist)
do
    print mv $file ${file}.Nov-12-2016
    mv $file ${file}.Nov-12-2016
done


I really wish Apple would just fix this bug once and for all. But until they do, when I see my Mailboxes are out of order I will run my script.

I cannot figure out how to get this simple ksh code to format correctly here, even though I read the help and tried the code and block quote buttons.  So the code as shown has too many empty lines and spaces.  Sorry for that.

Steve Price