Compacting folders: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
m ((Tools -> Options))
Line 7: Line 7:
==How to compact folders==
==How to compact folders==


The best way is to let Thunderbird do this automatically: "Tools -> Options -> Advanced -> Network & Disk Space -> Disk Space -> Compact folder when it will save over 100 kB -> OK."
The best way is to let Thunderbird do this automatically: "[[Menu differences in Windows, Linux, and Mac|Tools -> Options]] -> Advanced -> Network & Disk Space -> Disk Space -> Compact folder when it will save over 100 kB -> OK."


To compact all folders in an account manually, click the account on the left, and then click "File -> Compact Folders". Compacting an account may take from a few seconds to 10 minutes or more, depending on how much mail you have and how recently you last compacted the folders. If you have trouble doing this and the process stalls, try compacting one folder at a time by right-clicking on the folder and choosing "Compact This Folder". If you do not let Thunderbird compact automatically, you should do this regularly, at least once a week. If you do it daily, it will take only a fraction of the time.
To compact all folders in an account manually, click the account on the left, and then click "File -> Compact Folders". Compacting an account may take from a few seconds to 10 minutes or more, depending on how much mail you have and how recently you last compacted the folders. If you have trouble doing this and the process stalls, try compacting one folder at a time by right-clicking on the folder and choosing "Compact This Folder". If you do not let Thunderbird compact automatically, you should do this regularly, at least once a week. If you do it daily, it will take only a fraction of the time.

Revision as of 03:25, 1 June 2008

This article was written for Thunderbird but also applies to Mozilla Suite / SeaMonkey (though some menu sequences may differ).

When you delete or move a message most e-mail clients simply hide the message and mark it as ready for physical deletion later on. These hidden messages still remain in the folder. Even emptying the Trash does not physically delete them. These hidden messages are not physically removed until the folder is compacted. If you don't compact your mail folders periodically, they can grow very large, and erratic program behavior may occur.

Many users have never heard of compacting folders (not to be confused with compressing a file). However, most e-mail clients do this to improve performance by not requiring the e-mail client to rewrite the entire folder every time you delete a single message. The reason you might never have heard of compacting is that most e-mail clients default to automatically compacting the folder whenever a certain amount of space is wasted, while you have to enable this in Thunderbird.

How to compact folders

The best way is to let Thunderbird do this automatically: "Tools -> Options -> Advanced -> Network & Disk Space -> Disk Space -> Compact folder when it will save over 100 kB -> OK."

To compact all folders in an account manually, click the account on the left, and then click "File -> Compact Folders". Compacting an account may take from a few seconds to 10 minutes or more, depending on how much mail you have and how recently you last compacted the folders. If you have trouble doing this and the process stalls, try compacting one folder at a time by right-clicking on the folder and choosing "Compact This Folder". If you do not let Thunderbird compact automatically, you should do this regularly, at least once a week. If you do it daily, it will take only a fraction of the time.

Most people never have a problem compacting a folder when its online. However, if you get Nstmp folders that's due to the compacting being interrupted while Thunderbird is downloading new messages. You can avoid this by going offline before compacting (go to "File -> Offline -> Work Offline", or simply click on the icon in the bottom left corner.) It is rare for this to cause other problems but if you suspect it, experiment with going offline before compacting (ideally on a new known good folder). You can only compact IMAP accounts while you are online. However, this normally doesn't cause a problem since IMAP accounts only download the headers to the hard disk.

Other ways to compact folders

The Xpunge extension lets you add a button to empty the trash and compact the folders in multiple accounts (in one step). If you use the beta version you can set a timer to automate that.

The Mozilla Add-ons web site has several other extensions that add buttons to compact folders.

If you have an IMAP account there are two ways to automate compacting its folders.

  • If you check Tools -> Account Settings -> Server Settings -> Clean up ("Expunge") Inbox on Exit it will compact the Inbox folder when you exit Thunderbird. If you check "Empty Trash on Exit" it will also empty and compact the Trash folder when you exit.
  • If Tools -> Account Settings -> Server Settings -> "When I delete a message" is set to "Move it to the Trash folder" and you set mail.imap.expunge_after_delete to true using the Config editor Thunderbird will compact the folder immediately after you delete or move a message. Note: Thunderbird ignores the modified mail.imap.expunge_after_delete setting until after you have exited and restarted Thunderbird.

Problems when compacting

Compacting seems to take forever

Usually it only takes a couple of minutes to compact your folders unless your profile is over a gigabyte in size or your computer is slow. The worst that normally happens if you exit Thunderbird before it finishes compacting is that it fails to delete some nstmp temporary files that it created and you have to manually delete them.

If compacting takes a long time, the status bar at the bottom of the window may not remove the text about it compacting a folder when it finishes. It may also fail to update that text to mention the last folder in that account if you use "File -> Compact Folders". If you do something else that normally displays some text in the status bar, it should replace the message about compacting.

Compacting doesn’t seem to work

If compacting folders doesn't seem to work even for a single folder (where you right-click on the folder and choose "Compact This Folder"), it is possible that the folders and/or the .msf mail summary files are corrupted.

If the corruption is mild you frequently can fix it by deleting the .msf file(s).

  1. Exit Thunderbird.
  2. Make a temporary backup copy of your profile folder.
  3. In your profile folder, delete the files ending in .msf. Thunderbird recreates them when it starts.

If you’re using Windows a quick way to find the .msf files in all of the subfolders is to enter *.msf in Start->Search. On Windows XP, ensure that "Search hidden files" is chosen under "More advanced options"; on earlier versions of Windows, ensure that hidden files are viewable in Windows Explorer ("Tools -> Folder Options -> "View hidden files and folders").) Make sure that you only delete msf files in Thunderbird folders - other programs may use the same extension!

If the corruption is severe deleting the .msf files won't help much, and compacting the folder may just make it worse. You'll typically run into this only with the Inbox folder. Its much more vulnerable to corruption because many users tend to store lots of messages in it and they also frequently delete messages in it. Thats why its recommended that you don't permanently store messages in your Inbox folder, move them to other folders. You can fix the problem by replacing the corrupt folder with a new known good folder that you copied the messages to.

  1. Exit Thunderbird and make a temporary backup copy of your profile folder so that you can revert everything easily if necessary.
  2. Start Thunderbird, create a new folder and name it "TestFolder" (or similar).
  3. In the folder that is giving you problems (e.g. Inbox), select all the messages (highlight one and then press Ctrl+a) and copy them to TestFolder ("Message -> Copy" -> [account name] -> TestFolder"). In extreme cases (if Thunderbird and/or the computer become extremely sluggish), you may have to choose only a few emails at a time (choose one and then press Shift+Page Down or Page Up once or twice).
  4. Verify that all of the messages have been copied to TestFolder.
  5. Right-click on TestFolder and choose "Compact This Folder".
  6. Go to your profile folder and see if TestFolder looks like it has been compacted. It should be significantly smaller in size than the folder from which you copied the messages.
  7. If it looks like TestFolder can in fact be compacted successfully, exit Thunderbird, and go to your profile folder. Then:
    1. Rename the file that was giving you problems (e.g. rename "Inbox" to "InboxOLD") and delete its .msf file (e.g. "Inbox.msf").
    2. Rename the "TestFolder" folder to "Inbox" (or whatever the problematic folder was called) and delete "TestFolder.msf".
    3. Restart Thunderbird, and use it as usual. If compacting folders seems to work correctly during a test period (such as one week) then you can delete the folder "InboxOLD".

What if you don’t compact folders?

If you rarely or never compact folders, your mail files will accumulate more and more of the "hidden" messages that have been marked for permanent deletion but have not yet been removed. This can cause a lot of disk space to be used, and it can have a negative effect on Thunderbird’s performance.

  • Even if a mail folder seems to be empty or nearly empty, the mail file can become very large [1][2][3]. This wastes disk space, and when you back up your mail files for safekeeping, you will waste time backing up all these "hidden" messages as well.
  • When downloading messages, you might occasionally get duplicates of messages you’ve already received [4].
  • Messages that you have deleted or moved to other folders may unexpectedly reappear in their original folder [5][6].
  • Your anti-virus software might detect infected messages that you long ago deleted, even if you emptied the Trash [7].
  • It could cause problems when you try to defragment your hard disk [8].
  • Your Inbox might stay blank for minutes.
  • The new message count could become much larger than the actual number of new messages. A quick fix is to delete the .msf mail summary file for that folder—Thunderbird will create a new one the next time you run it—but this will not work if the folder is badly corrupted.

See also

External links