Last active
October 23, 2019 10:25
-
-
Save lgw4/9679415 to your computer and use it in GitHub Desktop.
Vacuum Apple Mail Envelope Index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
Speed up Mail.app by vacuuming the Envelope Index | |
Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/ | |
Originally by "pmbuko" with modifications by Romulo | |
Updated by Brett Terpstra 2012 | |
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compability | |
*) | |
tell application "Mail" to quit | |
set os_version to do shell script "sw_vers -productVersion" | |
set mail_version to "V2" | |
considering numeric strings | |
if "10.10" < os_version then set mail_version to "V3" | |
if "10.11" < os_version then set mail_version to "V4" | |
if "10.12" < os_version then set mail_version to "V5" | |
if "10.13" < os_version then set mail_version to "V6" | |
end considering | |
set sizeBefore to do shell script "ls -sk ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $1 / 1024'}" | |
do shell script "/usr/bin/sqlite3 ~/Library/Mail/" & mail_version & "/MailData/Envelope\\ Index vacuum" | |
set sizeAfter to do shell script "ls -sk ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $1 / 1024'}" | |
display dialog ("Mail index before: " & (round (sizeBefore * 100)) / 100 & " MB" & return & "Mail index after: " & (round (sizeAfter * 100)) / 100 & " MB" & return & return & "Enjoy the new speed!") | |
tell application "Mail" to activate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment