Apple Mail displays the number of unread messages in each folder in its sidebar:
Is there any way to make it display the folder's total message count (read plus unread) in addition to, or instead of, the unread message count?
Plugins/hacks welcome, as I’m guessing this won’t be a built-in option.
Best Answer
Since hacks are welcome:
The idea is to use AppleScript to rename folders. For example:
will be renamed to something like
where 34 is @REPLY's total message count.
A working implementation of such a script that renames mailboxes prefixed with
@
is (tested on OS X 10.8.2 with Gmail and AIM accounts):The effect of the script is shown in the following screenshots:
Another implementation that only renames mailboxes specified in a list would be (again, tested on OS X 10.8.2 with Gmail and AIM accounts)::
The effect of the script is shown in the following screenshots:
Both scripts set the message count:
@REPLY
->@REPLY (34)
and, only if necessary, that is, when the message count has changed, update it:
@REPLY (34)
->@REPLY (29)
My original idea was to run one of the scripts above (or some variation thereof) every time a mail is received with a rule in Mail>Preferences>Rules:
but it can also be added to
cron
to run every 10 minutes like this (see crontab (5) man page for crontab syntax explanation):Save the script to
/path/to/updateMailMessageCount.scpt
.Open Terminal and type:
to open your crontab file.
Move with the arrow keys to the end of the file, in case there are any other entries, and press
o
(lowercase letter o), which adds an empty line and goes into insert mode.Add this line (the
10
means "run every 10 minutes", change as necessary to match your needs):Press esc.
Save and close your crontab with
:x!
return (in case anything went wrong, type:q!
, press return and start over).(If you ever need to stop the cronjob, open your crontab file with
crontab -e
, position the cursor over the cronjob and typedd
to delete it. Then save the file as explained above.)You can use Launch Services, too (see this Apple developer document):
Create a script named
~/Library/LaunchAgents/updateMailMessageCount.plist
with contents (600 is the interval in seconds, that is, 10 minutes):Load the job with:
(If you ever need to stop the job, do:
launchctl unload ~/Library/LaunchAgents/updateMailMessageCount.plist
.)(My favorite as long time Linux sysadmin is
cron
, but note that, on OS X,cron
has been deprecated in favor of launchd. Both methods worked on my Mac running OS X 10.8.2.)If you wish to refresh the message count with a keyboard shortcut you can create a service (see http://www.macosxautomation.com/services/learn/index.html for more information):
Close Mail.
Open Automator in folder Applications and choose Service:
Select Utilities under Library and drag Run AppleScript to the empty pane on the right:
Configure the service to receive no input in Mail:
Replace the line
(* Your script goes here *)
with one of the scripts above.Save with a descriptive name like
Refresh Message Count
. The service will be saved to~/Library/Services/
.Now set up the keyboard shortcut:
Open System Preferences, select the Keyboard preference pane and then the Keyboard Shortcuts tab.
Select Services, scroll down to the service you previously added and set the keyboard shortcut to whatever you want with the following restriction: your shortcut shouldn't conflict with an existing shortcut in Mail. I've chosen controloption⌘R:
Open Mail. Note that there is a new service, accessible with controloption⌘R:
(For the curious: if you are wondering where service
Reply and Move Sent Message to Current Folder
above comes from, see How to save sent messages in same folder as message being replied to? -- warning: shameless plug.)Now press controloption⌘R, wait a few seconds and watch how the message count of the folders specified in the script get updated.
Caveats:
[Gmail]/All Mails
or theInbox
folders.Advantages: