Sep 22, 2009 13:45
Mac Mail (AKA Mail.app) has a distressing tendency to delete the mailbox cache of IMAP accounts when certain network operations are interrupted. Since preferred sorting column and direction are stored in plist files in this cache, that means that all folders reset to be sorted by date, ascending, which drives me nuts. After the latest such event, I finally sat down and figured out how to fix this automatically, in bulk:
% for f in ~/Library/Mail/**/Info.plist; do {
/usr/libexec/PlistBuddy -c 'Delete :DisplayInThreadedMode' $f;
/usr/libexec/PlistBuddy -c 'Delete :SearchSortDescending' $f;
/usr/libexec/PlistBuddy -c 'Delete :SearchSortOrder' $f;
/usr/libexec/PlistBuddy -c 'Delete :SortOrder' $f;
/usr/libexec/PlistBuddy -c 'Delete :SortedDescending' $f; } > /dev/null
/usr/libexec/PlistBuddy -c 'Add :DisplayInThreadedMode string no' $f;
/usr/libexec/PlistBuddy -c 'Add :SearchSortDescending string YES' $f;
/usr/libexec/PlistBuddy -c 'Add :SearchSortOrder string rank' $f;
/usr/libexec/PlistBuddy -c 'Add :SortOrder string received-date' $f;
/usr/libexec/PlistBuddy -c 'Add :SortedDescending string YES' $f;
done
This should have the same effect as wiping out all the plists, allowing Mail to regenerate them in their default state, and then going through and manually changing every folder to sort by date, descending.
(And yes, there are probably better, or at least more concise, ways to code the script, but this was the easiest to write, and shell arrays suck.)
computers,
incompetence