Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Reduce mailbox sizes in Mail Apps
I was recently clearing out space from my hard drive and noticed that my Inbox in my Mail folder had grown quite large, around 80 MB or so. Mail told me that I only had about 7 MB of messages, so I wanted to figure out what was taking up all that extra space.

I went into ~/Library/Mail and found the offending mailbox, INBOX.imapinbox (the inbox for my .Mac account). Selecting "Show Package Contents" from the contextual menu showed me that the file inside the inbox that was taking up the most room was mbox.SKIndex, weighing in at a hefty 70.8 MB.

This appeared to be the file that Mail stores its index information for each mailbox. To test my theory, I quit Mail, moved the mbox.SKIndex (along with another file called mbox.SKIndex.isValid) out of the mailbox package and onto my desktop, and then relaunched Mail. Sure enough, Mail started reindexing the inbox to replace the missing index. When it was done, I went and looked in the mailbox package, and there was a new index file, but it was only 576 KB!

The lesson is that it appears that Mail does not flush out old index data from messages that have been removed from a mailbox, so the file just keeps getting larger and larger. So, if you want a quick way to reduce your mailbox sizes (especially boxes that see a lot of traffic), this is a very nice solution.

The Finder won't let you do a search inside the mailbox bundles for the index files, but you can search from them from the command line using the find command. Make sure you quit Mail, then cd into your Mail folder by typing cd ~/Library/Mail. To find all the index files in all your mailboxes, type:
% find . -name "mbox.SKindex*" -print
This will print out the paths of all the files that you'll want to delete. You can also conveniently delete them using find:
% find . -name "mbox.SKindex*" -delete
This will clear out the indexes for all your mailboxes. You can then relaunch Mail and click on each individual mailbox to start it reindexing.

[robg adds: Testing this on my machine, I freed up 100mb of drive space. Do a Get Info on the Mail folder before and after to see the effects. You can also do this within Mail, I believe, by using the Rebuild Mailbox option, but then you have to do one mailbox at a time.]
    •    
  • Currently 1.20 / 5
  You rated: 1 / 5 (5 votes cast)
 
[25,206 views]  

Reduce mailbox sizes in Mail | 21 comments | Create New Account
Click here to return to the 'Reduce mailbox sizes in Mail' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Reduce mailbox sizes in Mail
Authored by: bkitchman on Aug 28, '03 11:31:38AM

This does nothing in 10.3. Seems as though they rewrote the way indexing is handled.



[ Reply to This | # ]
10.3?
Authored by: Loren on Aug 28, '03 02:02:21PM

I am sure what you mean to say is that you imagine it won't happen in 10.3, as there is no legal way for you to tell us anything else.



[ Reply to This | # ]
10.3?
Authored by: broderik on Aug 28, '03 02:13:48PM

Not necessarily, he could be a developer who has the latest version of 10.3 that's available on the ADC site.



[ Reply to This | # ]
10.3?
Authored by: maxgraphic on Aug 28, '03 03:14:10PM

In which case he'd be violating his NDA, no?

---
Design your own business cards and more
http://www.designyourowncard.com/



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: mmellis on Aug 28, '03 11:33:08AM

If your mailbox names have spaces in them you might want to make the following change to the suggested command line:

find ~/Library/Mail -name "mbox.SKindex*" -print0 | xargs -0 ls -l

This uses nulls for delimiters instead of spaces.

...Mark



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: Anonymous on Aug 28, '03 12:18:00PM

Is this not the same as selecting Mailbox -> Rebuild Mailbox from the menu?



[ Reply to This | # ]
Doh
Authored by: Anonymous on Aug 28, '03 12:21:43PM

Didn't see robg's edit there. Pardon me.



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: kyngchaos on Aug 28, '03 01:09:26PM

I tried the Mailbox->Rebuild Mailbox in Mail and it didn't reduce the size of the index for me. Only deleting the index file reduced the index size.



[ Reply to This | # ]
No need to use Get Info
Authored by: dshirley on Aug 28, '03 04:48:54PM

Since you're already in the shell, there's no need to go to the Finder, find the Mail folder and then do a Get Info on it. Instead, assuming you are in your home directory, type the following:

du -ks Library/Mail

This will give you a total disk usage figure in kilobytes for the mail folder. Run this before and after and glory in the difference!

---
Quidquid latine dictum sit altum viditur



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: LFransson on Aug 28, '03 06:11:47PM

Note that you must be using the original version of find supplied with OS X, located in /usr/bin. If you're like me and have the GNU findutils installed via Fink, that version of find (located in /sw/bin) does not have the -delete option.

---
Larry Fransson
Seattle, WA



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: Dibbler on Aug 28, '03 11:08:18PM
For GNU find, you should type:
find . -name "mbox.SKindex*" -exec rm {} \;

[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: dwchin on Aug 29, '03 12:28:40AM

For tcsh, add a backslash before the semicolon

find . -name "mbox.SKindex*" -exec rm {} \;



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: Dibbler on Aug 29, '03 03:56:29PM

I had to do that in bash too. I could have sworn the backslash was there when I pasted the command into the comment box. I guess I just need to proofread more carefully.



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: ruebenschuss on Aug 29, '03 03:58:23AM

A few comments on this:

I love to keep *all* of my mails in the actual program, just in case I want to see what I wrote to somebody 7 years ago. Thus, I have approx. 18.000 Mails in a few subfolders of my Mail.app and Finder sais that ~/Library/Mail has 316 MB. So I was desperate to try this hint.

Here's what I did in the Terminal:
[microlap8:~/Library/Mail] becker% /usr/bin/du -ks .
329076 .
[microlap8:~/Library/Mail] becker% /usr/bin/find . -name "mbox.SKindex*" -delete
[microlap8:~/Library/Mail] becker% /usr/bin/du -ks .
284696 .

<Rebuilding Indexes in Mail>

[microlap8:~/Library/Mail] becker% /usr/bin/du -ks .
307260 .

I just want to make sure that everybody remembers to recreate the indexes first, before calculation the gain in space. I can assume now that I saved 22MB. Funny enough, the Finder still shows 316MB and the GetInfo-details are not better.

I would like to mention one more thing that came to my mind again when reading this hint: the other day my girlfriend complained that there was something wrong with her Mail.app and she had trouble with mails appearing and dissappearing and INBOX being too large. When I looked at it, she had "View / Hide-deleted-messages" turned off and had marked thousands of emails deleted but they remained in the mailbox and were not deleted but only marked as... Turning on that switch and really deleting the mails did help.

I wonder if the issue of some people saving lots of space by deleting the index-files and others not, could be related to how they usually trash their mails. (?)



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: latenightmac on Aug 29, '03 03:59:17AM

Any help with this in Terminal it just says "too many arguments" when you try it....and I thought that was just the US and France!



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: josephaw on Aug 29, '03 09:39:36AM

Don't copy the "%" percent sign.
Joe



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: pcunixapl on Aug 29, '03 12:01:31PM

WARNING:

I had serious problems with my Sent mbox (which was very large).

After removing the indexes, Mail kept crashing while trying to rebuild Sent

I had to manually vi the mbox and move half of it elsewhere before it would rebuild without crashing..


---
--
Tony Lawrence



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: gsdali on Sep 01, '03 01:01:46PM

One thing to note is that when you perform this task you loose everything that Mail uses to do auto complete. So if, like me, you have been so lazy as to not have added everyone into your address book you will loose the ability to find email addresses by auto complete, at least until you send them a mail again.

Worth the 80Mb space saving though.

---
--
Ed Lynch-Bell
dali@zerointegrity.co.uk



[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: mactigger on Sep 03, '03 10:07:10AM

Something very odd happened when I tried this hint. I quit Mail, ran the command in terminal, reopened Mail and all was fine. The indexes were rebuilt as I looked in each mailbox. So I thought all was good and shut down for the night.

The next day when I opened Mail, ALL of my mailboxes were gone, and there was no mail in the inbox, but it retained all of my account settings. It's almost as if my /Library/Mail folder was deleted and then recreated when I opened mail. I had a backup from about 5 days ago, but I still lost a considerable amount of mail that had been filed since then.

Any ideas?



[ Reply to This | # ]
Rebuild Mailbox doesn't affect the .SKindex files
Authored by: mkhaw on Oct 28, '03 12:37:20PM
Rebuild Mailbox, at least in Mail.app version 1.2.5 (v552) on 10.2.8, doesn't rebuild the .SKindex files. Instead, sometimes newer messages get added into an Incoming_Mail file in the .mbox directory (with a corresponding Incoming_Table_of_Contents file), and Rebuild Mailbox merges them into the corresponding mbox and table_of_contents files. To get the .SKindex files rebuilt, it appears necessary to delete them.

[ Reply to This | # ]
Reduce mailbox sizes in Mail
Authored by: carsten on Dec 21, '04 08:49:34PM

Nice hint, THANK YOU! I saved 122,432 Kb after rebuilding all the indices (…by searching the entire message of all mailboxes for the letter a, quit Mail and checked the disk usage, then relaunched Mail and clicked on each mailbox--waiting until the Activity Viewer window was finished before clicking on the next folder. Not much change in size, only a few k, so I guess searching the entire content of all messages did the trick of rebuilding the indices).

Before:


$ du -ks ~/Library/Mail
710408    ~/Library/Mail

After:


$ du -ks ~/Library/Mail
587976    ~/Library/Mail

Running 10.3.7, Mail(.app) 1.3 (v606/619).

Strange thing is, "find" no longer finds any SKindex files. So far all is fine though and searches work (I really deleted all deleted messages beforehand).

Maybe the SKindex files are no longer used in 10.3's Mail?--and they were just sitting there all this time wasting space?

[ Reply to This | # ]