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

10.4: Free up disk space from Mail.app after upgrade Apps
Tiger only hintAfter upgrading to Tiger I found that Mail.app exploded the mailbox into individual files. However, my upgrade left the (old) mbox files around which consumed a considerable amount of disk space. I looked at the modification times of these old mbox files and saw that they had not been modified since the upgrade, so I took the plunge and removed the mbox files whithout any adverse effect.

If you want to do the same (please only for Mail.app 2.0!), here a quick set of shell commands that will do the trick:
$ cd ~/Library/Mail/Mailboxes
$ find . -name mbox -exec rm {} \;
[robg adds: If you have a CD-R or DVD-R, I'd highly suggest burning old mbox files as opposed to deleting them -- at least until you're sure everything is working as you wish it to. Alternatively, just move them to another drive or partition for a while, then remove them from there.]
    •    
  • Currently 1.50 / 5
  You rated: 1 / 5 (4 votes cast)
 
[19,957 views]  

10.4: Free up disk space from Mail.app after upgrade | 12 comments | Create New Account
Click here to return to the '10.4: Free up disk space from Mail.app after upgrade' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Free up disk space from Mail.app after upgrade
Authored by: club60.org on May 23, '05 01:41:18PM

Warning! Don't run this command before inspecting the folders you are going to delete (the above command will delete all folders which name contains 'mbox'.

While inspecting my system (I used a lot of mailboxes in Jaguar), I see that some active and converted mailboxes still use '.mbox' suffix.



[ Reply to This | # ]
10.4: Free up disk space from Mail.app after upgrade
Authored by: adrianm on May 23, '05 01:42:13PM

For me, many of my mbox files were rooted from the directory above.

eg.

~/Library/Mail/POP-username@host/mailboxname.mbox/mbox

Also, only POP3 mailboxes had large mbox files. All the rest were zero size.



[ Reply to This | # ]
10.4: Free up disk space from Mail.app after upgrade
Authored by: dturley on May 23, '05 02:15:33PM

Danger Will Robinson!!!

If you have nested mailboxes, the top level mailboxes still have the mbox suffix. Don't do this!

As an experiment, I did drag on of those mbox files to the desktop, and all the mailboxes nested below disappeared.



[ Reply to This | # ]
10.4: Free up disk space from Mail.app after upgrade
Authored by: geohar on May 23, '05 02:37:55PM
Please, please understand that find does not do substring search by default on the name unless you specify a pattern (eg. 'foo*', note that you need the quotes to prevent the shell interpretting it as a glob). Try

cd ~/Library/Mail/Mailboxes
find . -name mbox
to see what would be removed. Additionally, the rm is a shell command, not a find builtin, so without a -rf flag, it will not remove directories. This finds files only, though you could be extra specific with the following clause:

cd ~/Library/Mail/Mailboxes
find . -name mbox -not -type d
Which specifically disallows directories from being found. Sure, if you get it wrong, it could be dangerous, however, I agree with dschroet's hint and I believe the old mbox files are no longer used - mail must be stored in .elmx files so that spotlight can find a single file containing the required terms. So I believe the hint to be safe. YMMV.

[ Reply to This | # ]
Command Line FUD
Authored by: zeusr on May 23, '05 04:09:41PM
Warning! Don't automatically listen to people that know how to make HTML items bold or know pop culture references or can string together three exclamation points in a row!!!

And please read the man page for the command you're FUD'ing. Without a wildcard, 'find' WILL NOT match '.mbox'. To do so, you have to add a splat ('*') to 'mbox', PLUS put it in quotes (single or double). The simplest way to check to see what will be deleted is to remove everything from '-exec' on and add ' | less' to the end of it. The command will be:


find -name mbox | less

It will show the files that are found and that would be deleted with the posted command.

Also, the 'rm' command WILL NOT delete directories with items inside of it WITHOUT the '-R' tag.

The posted command CAN NOT remove directories with items in it, even if it COULD find directories ending in 'mbox', which it CAN NOT since the command is search for files and directories with the ENTIRE name being 'mbox'.

The command you are creating FUD about would look like this:


$ find . -name '*mbox' -exec rm -R {} \;

This is ranting, but I know the *NIX portion of OS X can be a big, scary monster for those that fear change, but please make sure you know what you're talking about before warning others about dangers that aren't there. The Terminal isn't the Boogie Man.

I can't believe I even have to point this out...

[ Reply to This | # ]

Command Line FUD
Authored by: geohar on May 23, '05 04:14:45PM

;) We must have posted at exactly the same time. Like you, I don't want to seem like I'm flaming here, but it is really important that information here which is presented as fact is correct.

Btw. 'man and apropos' are you friends ;)



[ Reply to This | # ]
10.4: Free up disk space from Mail.app after upgrade
Authored by: echo on May 23, '05 06:02:09PM

Safe from the danger of command line syntax, I had done this cleanup from the finder, where I could determine the difference of the new + old files + directories. It's nice to have a cleaner view of this directory structure. After import, more than twice the files are no longer used.



[ Reply to This | # ]
10.4: Free up disk space from Mail.app after upgrade
Authored by: saeedi on May 23, '05 07:16:14PM
Don't forget to delete the following files as well:

mbox.SKindex*
Incoming_Table_of_Contents
Incoming_Mail
content_index
table_of_contents


I would also use the following command to see how much space is being used up. For example, to see the space taken by content_index use the command:

find ~/Library/Mail -name "content_index" -exec ls -al {} \; | awk '{s+=$5} END {print "Sum: " s}' 
- Steve

[ Reply to This | # ]
IMAP is different...
Authored by: aamann on May 23, '05 09:19:05PM
If you have locally cached IMAP folders, those messages have changed on disk as well - there are some more folders/files to delete.

I successfully used the following commands to clean up the pre-Tiger stuff from my local POP and IMAP folders:
find ~/Library/Mail -path "*.imapmbox/Cached*" | while read cachefolder; do rm -fr "${cachefolder}"; done
find ~/Library/Mail -path "*.mbox/mbox" | while read mboxfile; do rm -fr "${mboxfile}"; done
find ~/Library/Mail -path "*.*mbox/content_index" | while read indexfile; do rm -fr "${indexfile}"; done
find ~/Library/Mail -path "*.mbox/table_of_contents" | while read tocfile; do rm -fr "${tocfile}"; done
(This was posted on the Apple discussion board a while ago)

[ Reply to This | # ]
Find can exec commands too
Authored by: jpbjpbjpbjpb on May 24, '05 01:38:34PM
FYI, find can do the rm for you as well, you don't need to pump the find output into a script.

find ~/Library/Mail -path "*.imapmbox/Cached*" -exec rm -v '{}' ';'

find ~/Library/Mail -path "*.mbox/mbox" -exec rm -frv '{}' ';'

find ~/Library/Mail -path "*.*mbox/content_index" -exec rm -frv '{}' ';'

find ~/Library/Mail -path "*.mbox/table_of_contents" -exec rm -frv '{}' ';'


[ Reply to This | # ]
Find can exec commands too
Authored by: zojas on Jun 02, '05 02:23:43AM
even better, use xargs. the -exec flag does a fork for each and every file. (i.e., a new process is launched for each file!)

with xargs, there will only be the find process, the xargs process, and a few rm processes (eventually the command line to rm will get too long and xargs will have to launch another rm).

when you have an imap inbox with 9000 messages in it like I do it's a big deal. I ran the first find without removing the files, just piping the list of files to 'wc' to see how many there were. there were 20560 files! In my case, I'll get about 20 processes launched using xargs, as opposed to 20561 if I use the -exec flag.

try this:

find ~/Library/Mail -path "*.imapmbox/Cached*" -print0| xargs -0 rm
find ~/Library/Mail -path "*.mbox/mbox" -print0 | xargs -0 rm -frv
find ~/Library/Mail -path "*.*mbox/content_index" -print0 | xargs -0 rm -frv
find ~/Library/Mail -path "*.mbox/table_of_contents" -print0 |xargs -0 rm -frv

(the -print0 and -0 arguments are just to take care of files with spaces in the name; they are 'zeros' not 'ohs')

the first find command (which deleted 20000 files) only took 48seconds on my 700Mhz g3 ibook.

before deleting all those files, my ~/Library/Mail was 1.3G, afterwards it was only 677MB.

and mail.app still works fine, so those seem to be the correct files to delete.



[ Reply to This | # ]

Find can exec commands too
Authored by: Kalak on Jul 07, '05 11:52:10AM

I'm been using find and exec for a while now, but I didn't know that xargs forked once (generally). I'll have to try to get used to using it instead, and I know the overhead for some of the find -exec commands I've run is noticable, so this should save a lot.

---
--
Kalak
I am, and always will be, an Idiot.



[ Reply to This | # ]