Thursday’s tip about trimming the fat out of Mail’s Envelope Index for a leaner, faster Mail.app got a fair bit of coverage.
Two readers liked it so much that they have produced applescripts to do the job.
Sebastian Morsch
has written a script that quits Mail, runs the sqlite commands and then relaunches Mail at the end of the process. You can get the script
from his web site.
“pmbuko” has written another, which does the same thing (modified as suggested in the comments below by Romulo — Thanks!) :
tell application “Mail” to quit
set sizeBefore to do shell script “ls -lah ~/Library/Mail | grep -E ‘Envelope Index$’ | awk {’print $5′}”
do shell script “/usr/bin/sqlite3 ~/Library/Mail/’Envelope Index’ vacuum”
set sizeAfter to do shell script “ls -lah ~/Library/Mail | grep -E ‘Envelope Index$’ | awk {’print $5′}”
display dialog (”Mail index before: ” & sizeBefore & return & “Mail index after: ” & sizeAfter & return & return & “Enjoy the new speed!”)
tell application “Mail” to activate
It gives you some feedback on what happens:
You can grab the text of the second script above or download it in a zip file I’ve uploaded to the site.
Obviously, the law of diminishing returns is in play here. The first time you run it, the benefit is tremendous. Run it again soon after and there is not so much bloat to remove and, hence, not as great an improvement.
Still, as some have pointed out, this should be a regular maintenance routine for Mail. You can wait for the Mail Development Team to implement it or with one of these rules and iCal, you can automate it yourself.
All you need to do is create a recurring event in iCal and use the “Run script” option in the alarm feature to run the script.
So, save the script somewhere sensible — I saved mine in the ~/Library/Scripts/ Applications/Mail folder.
Create the event.
Click on the alarm field in the event’s information pane, and select “Run script”.
When prompted, navigate to the script and select it.
I’ve added an end for the event after 100 instances because my Palm really hates events with no end date. You may be luckier.
Now you can enjoy a lean Envelope Index long after you have forgotten about the tip.
[With thanks to Sebastian and pmbuko]
UPDATE: If you prefer Automator to AppleScript, Steve Weintraub has created an Automator action
to do the same thing.
Tags:
Apple Mail,
Apple Mail Tips,
applescript,
automate,
envelope,
iCal,
mail.app,
Productivity,
scripts,
speed,
sqlite
Related posts