I am working on a archive migration, in which I am extracting mail from 700GB of PST files, and sending it to an email archive. Once a message was extracted, it is deleted from the PST file using a custom utility.

However this leaves me with 700GB of mostly empty PST files.

For compliance reasons, I need to retain the messages that could not be extracted, and I need to reclaim disk space too.

Is there a way to bulk compact the PST files? I can't find much useful software online to do this.

If I take a 500MB PST file and zip it, I am left with a 230MB archive. However if I use Outlook 2007 to compact it, I am left with a 15MB PST.

Anyone have any ideas on how to bulk compact thousands of PST files? I'm not looking for a solution like CompressPST which removes attachments and whatnot, as the files are 99% empty.

I couldn't find any command line switches for outlook to accomplish this.

  • @Techie007 Thanks. I know how to compact PST files manually, it's just that I have a thousand or so of them.
    – beeks
    Nov 6, 2014 at 16:23
  • @sunk818, that defeats the purpose of bulk compacting hundreds of gigs of PSTs. How would that work if you are given a 1TB drive of PST files from dozens of different users?
    – beeks
    Nov 15, 2014 at 18:25

2 Answers 2


OK, I accomplished this using SmartPST (Freeware) and AutoIT (Freeware.)

With SmartPST I can bulk add PST files into my Outlook profile. Drag and drop.

And the following AutoIT script I dug up iterates through each and compacts. Run it in a VM to not get your current work avoided.

This ended up being the best I could ask for. A drag and drop, then click solution. :) IT Automation doesn't get better than that.

#include <GUIListView.au3>
SplashTextOn("Compacting now", "This may take hours...", 250, 40)
;//Runs the mail application that is in control panel.
$Path = FileGetShortName(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cpls", "mlcfg32.cpl"))
Run(@SystemDir & "\control.exe " & $Path)
Opt("WinTitleMatchMode", 4)
WinWait("Mail Setup - Outlook", "Setup e-mail accounts and dire")
ControlClick("Mail Setup - Outlook", "Setup e-mail accounts and dire", "Button2")
WinWait("Account Settings", "AcctMgr Tab")
;//Gets list of data files listed
$sTitle = "Account Settings"
$hWnd = WinGetHandle($sTitle)
If @error Then
 MsgBox(0, "Error", "Unable to find window")
$hlist = ControlGetHandle($hWnd, "", "[CLASS:SysListView32; INSTANCE:2]")
If @error Then Exit
$arraycount = _GUICtrlListView_GetItemCount($hlist)
Local $ltext[$arraycount]
$i = 0
 $ltext[$i] = _GUICtrlListView_GetItemText($hlist, $i)
 $i = $i + 1
Until $i = $arraycount
;//Goes into each listed Data file and compresses them
$b = 0
 _GUICtrlListView_ClickItem($hlist, $b, "left", False, 2)
 WinWaitActive("Outlook Data File")
 ControlClick("Outlook Data File", "", "[CLASS:Button; INSTANCE:2]") ; click Compact Now
 If WinExists("Compact Now") Then WinWaitClose("Compact Now")
 WinClose("Outlook Data File")
 $b = $b + 1
Until $b = $arraycount
WinClose("Outlook Data Files")
WinClose("Account Settings")
WinClose("Mail Setup - Outlook")
MsgBox(64, "Outlook", "All accounts were processed." & @CRLF & "Closing in 5 seconds...", 5)

Thanks Beeks, this worked great for me after a small tweak.

On my Windows 8.1 PC running Office 2013, the following two lines didn't work to open the Mail control panel because the registry key didn't exist.

$Path = FileGetShortName(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Current>Version\Control Panel\Cpls", "mlcfg32.cpl"))
Run(@SystemDir & "\control.exe " & $Path)

I found I could open the Mail control panel without having to mess with the registry by using a PowerShell script to first open the Mail control panel and then call an AutoIT script to do the rest:

# Open Mail control panel

Show-ControlPanelItem Mail*

# Call script to compact all Outlook PST files, waiting for the script to
# complete before moving on to the next step in the PowerShell script.

Start-Process "C:\Users\XXX\Documents\Compact all PST files.au3" -Wait
  • Thanks for posting. I just installed Office 2016, the registry key will probably change again.
    – beeks
    Nov 2, 2015 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .