Splitting huge pst file

Discussion in 'Software' started by luvsublime808, Nov 13, 2006.

Thread Status:
Not open for further replies.
  1. luvsublime808

    luvsublime808 Private E-2

    Does anyone know of any good programs taht can split a large pst file (about 1.8 gigs) don't ask me how it got that big, its not mine, its just some user i have to support.


    I thought that Outlook wouldn't let you get above a gig on a pst file.

    This is Outlook 2002 (aka OutlookXP)
     
  2. Yargwel

    Yargwel MajorGeek

    have a look here
     
  3. matt.chugg

    matt.chugg MajorGeek

    COuldn't you reimport it into outlook and export it in sections? I.E. export just the outbox as one file and the inbox as one file and all the rest as one file ?
     
  4. luvsublime808

    luvsublime808 Private E-2

    the problem with the 1st program is, Outlook has special data at the start of the PST file, this will not copy it, rendering both the new pst files useless.

    the 2nd problem I'm having with this, Outlook cannot load the file. So I cannot really do anything with the file untill its sized down... It seriously crashes outlook within a few min of trying to open the file. Its about 1.82GBs (yea i know, stupid users)

    we left it sitting there overnight to see if it could open, and it still wouldn't.
     
  5. theefool

    theefool Geekified

    Something to give a shot, since I'm sure you have a backup:

    No, this doesn't split it up, but, maybe you have errors with that .pst file.

    Yes, I have seen .pst files larger.

    Source: http://office.microsoft.com/en-us/outlook/HA010563001033.aspx
     
  6. theefool

    theefool Geekified

    This script may be what ye need!

    Code:
    Web Listing 1: PSTSplitter.vbs
    ' ==================================================================
    '
    ' PSTSplitter.vbs - 8/29/2002
    '
    ' Purpose: Moves all MailItems between the specified date
    ' range into a new .pst file, effectively splitting the archive
    ' in the event that older MailItems need to be taken offline.
    '
    ' Syntax: PSTSplitter.vbs <startdate> <enddate> <pstfile> [newfilename]
    ' Example: PSTSplitter.vbs 1/1/2000 12/31/2000 q:\archive.pst q:\newarchive.pst
    ' Note: If newfilename isn't specified, a new filename will 
    ' automatically be generated based on the old archive name
    ' and the specified date range. 
    '
    ' All currently opened Personal Folders (.pst) files will be
    ' detached from Outlook to avoid any conflicts when
    ' performing the split.
    '
    ' You will need to manually compact the old archive to
    ' reclaim the space you've now gained by moving the
    ' MailItems to the new archive.
    '
    ' Requirements: - Outlook 2000 or later configured with 
    '                 an appropriate Outlook profile
    '               - Windows Script Host (WSH) 2.0 or later (download WSH 2.0 at
    '                 http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshost). 
    '                 Use cscript.exe rather than wscript.exe.
    '
    ' Copyright: Steve Seguis
    '            scriptmaster@scripthorizon.com
    '            http://www.scripthorizon.com
    '
    ' ==================================================================
    Option explicit
    Dim olApp
    Dim olNameSPace
    Dim inbox
    Dim myfolder
    Dim pAItems
    Dim archive
    Dim newarchive
    Dim startDate
    Dim endDate
    Dim fs
    Dim rootStoreID
    Dim archStoreID
    Dim newarchStoreID
    Dim archFileName
    Dim newarchFileName
    Dim oArgs
    
    '=== Constants required for Outlook functions.
    Const olFolderCalendar = 9
    Const olFolderInbox = 6
    
    Const mailItemClass = 43
    Const mailDefaultItemType = 0
    
    '=== Retrieve command-line arguments.
    Set oArgs = Wscript.Arguments
    
    '=== User must specify all parameters or else show usage.
    If oArgs.Count < 3 Then
    	Wscript.Echo "USAGE: PSTSplitter.vbs <startdate> <enddate> <pstfile> [newfilename]"
    	WScript.ECHO "Example: PSTSplitter.vbs 1/1/2000 12/31/2000 q:\archive.pst q:\newarchive.pst"
    	WScript.Echo ""
    	WScript.ECHO "Note: If newfilename is not specified, a new filename will automatically”
    	WScript.ECHO "      be generated"
    	Wscript.Quit 1
    End If
    
    WScript.Echo "Defining date ranges..."
    startDate = DateValue(oArgs(0))
    WScript.Echo "Start Date: " & startDate
    endDate = DateValue(oArgs(1))
    WScript.Echo "End Date: " & endDate
    archFileName = oArgs(2)
    
    If startDate > endDate Then
    	WScript.Echo "INVALID: Start date is after end date"
    	WScript.Quit 1
    End If
    
    set olApp = CreateObject("Outlook.Application")
    set olNameSpace =olApp.GetNameSpace("MAPI")
    
    ' === Get reference to mailbox.
    rootStoreID = olNameSpace.GetDefaultFolder(olFolderInbox).parent.storeId
    
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    
    If NOT fs.FileExists(archFileName) Then
    	WScript.Echo "Archive file doesn't exist"
    	WScript.Echo “Make sure the path to the .pst file contains no spaces”
    	WScript.Quit 1
    End If
    
    If oArgs.Count = 4 Then
    	' === New archive name was specified.
    	newarchFileName = oArgs(3)
    Else 
    	' === Generate a filename for new archive.
    	newarchFileName = genNewFilename(archFileName, oArgs(0), oArgs(1))
    End If
    
    WScript.echo "Current Archive: " & archFileName
    WScript.echo "New Archive: " & newarchfilename
    
    WScript.echo "Closing any opened .pst file to avoid conflict"
    Dim i, temp
    For i = olNameSpace.Folders.count To 1 Step -1
    	temp = olNameSpace.Folders(i).storeID
    	If Left(temp,75) <> Left(rootStoreID,75) Then
    		' === At least the first 75 digits of the rootStoreID
    		'     are the same for items that aren’t Personal Folders.
    		'     Since they're not equal, this must be a 
    		'     Personal Folder. Close it.
    		olNameSpace.RemoveStore olNameSpace.Folders(i)
    	End If
    Next
    
    Wscript.echo "Opening .pst files"
    olNameSpace.AddStore archfilename
    
    For i = olNameSpace.Folders.count To 1 Step -1
    	temp = olNameSpace.Folders(i).storeID
    	If Left(temp,75) <> Left(rootStoreID,75) Then
    		' === This must be the old archive. Save the storeID
    		'     and reference to the MAPIFolder instance.
    		set archive = olNameSpace.Folders(i)
    		archStoreID = temp
    	End If
    Next
    olNameSpace.AddStore newarchfilename
    For i = olNameSpace.Folders.count To 1 Step -1
    	temp = olNameSpace.Folders(i).storeID 
    	' === We need to get the reference to the MAPIFolder instance
    	'     of the new .pst file by looking for .pst files currently
    	'     opened in Outlook (using AddStore). We also need to make
    	'     sure that this storeID isn’t the same as the one for
    	'     the old archive, or we will be referencing the old
    	'     archive rather than the new one.
    	If (Left(temp,75) <> Left(rootStoreID,75)) AND _
    	   (temp <> archStoreID) Then
    		set newarchive = olNameSpace.Folders(i)
    		newarchStoreID = temp
    	End If
    Next
    
    WScript.Echo vbTab & archive
    WScript.Echo vbTab & newarchive 
    
    createFolders archive, newarchive, startDate, endDate
    
    WScript.Echo "Closing .pst files"
    
    olNameSpace.RemoveStore archive
    olNameSpace.RemoveStore newarchive
    WScript.Echo "SUGGESTION: open up the old archive in Outlook and compact it " & _
    	     "to reclaim the lost space" 
    WScript.Quit 0
    
    ' =====================================================================
    ' Creates folder structure in new archive and moves MailItems that
    ' are within the specified start (sDate) and end dates (eDate).
    ' This is a recursive subroutine that has the stop condition of
    ' the folder not having any subfolders.
    ' =====================================================================
    Sub createFolders(root, newarch, sDate, eDate)
    	Dim rootNS 
    	Dim rootFolders
    	Dim newRoot
    	Dim subRoot
    	Dim newSubRoot
    	Dim i
    	Dim j
    	Dim time
    
    	set rootNS = root
    	set rootFolders = root.Folders
    	set newRoot = newarch
    	
    	' === Check each MailItem in the current folder if they are
    	'     within the date range.
    	For j=rootNS.Items.Count to 1 Step -1
    		WScript.Echo "Checking " & rootNS.Items(j).Subject
    
    		IF (rootNS.Items(j).CreationTime > sDate) AND _
    		   (rootNS.Items(j).CreationTime < eDate) AND _
        		   (rootNS.Items(j).Class = mailItemClass) Then
    			' === This item is within the start and end dates.
    			WScript.Echo "Moving " & rootNS.Items(j).Subject
    			rootNS.Items(j).Move newRoot
    			If Err.number > 0 Then
    				WScript.Echo "Error: " & Err.Description
    			End If
    		End If
    	Next
    
    	if rootFolders.count = 0 Then
    		' === Stop condition reached
    		Exit Sub
    	End If
    
           	On Error Resume Next
    
    	' === Create each subfolder of this folder.
    	For i = 1 to rootFolders.count 
    		set subRoot = rootNS.Folders(i)
    
    ‘ Create only folders with default item type set to mailItem.
    		If subRoot.DefaultItemType <> mailDefaultItemType Then
    			' === Create the folder in the new archive
    			WScript.Echo "Creating " & subRoot
    			newRoot.Folders.add("" & subRoot)
    			' === Set the current subfolder in the new archive
    			'     to the newly created folder above.
    			set newSubRoot = newRoot.Folders("" & subRoot)
    
    			WScript.Echo subRoot & " " & subRoot.items.count
    			If subRoot.class = 2 Then	
    				' === This is a MAPIfolder. Call this
    				'     subroutine with the root and newroot as
    				'     the current subdirectories.		
    				createFolders subRoot, newSubRoot, sDate, eDate
    			End If
    		End If
    
    	Next
    
    End Sub
    
    '=======================================================================
    ' Generates filename for new archive.
    '=======================================================================
    Function genNewFilename(str, sDate, eDate)
    	sDate = replaceText(sDate,"/","")
    	sDate = replaceText(sDate,"\\","")
    	eDate = replaceText(eDate,"/","")
    	eDate = replaceText(eDate,"\\","")
    	Dim pos, tempname
    	pos = InStr(1,str,".pst",1)
    	If pos <> 0 Then
    		tempname = Left(str,pos-1) 
    	Else
    		tempname = str
    	End If
    	
    	genNewFilename = tempname & "_" & sDate & "_" & eDate & ".pst"	
    End Function
    
    '=======================================================================
    ' Function to simply replace any occurrence of oldstr with 
    ' newstr in str1.
    '=======================================================================
    Function ReplaceText(str1, oldstr, newstr)
    	Dim regEx
    	Set regEx = New RegExp
    	regEx.Pattern = oldstr
    	regEx.IgnoreCase = True
    	regEx.Global = True
    	ReplaceText = regEx.Replace(str1,newstr)
    End Function
     
Thread Status:
Not open for further replies.

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds