'--------------------------------------------------------------------------------------------- ' Written by Carsten Cumbrowski (http://www.cumbrowski.com/) ' Use this script at your own risk ' ' Steps that you must have done before you run this script ' 1. Created a backup copy of your current Outlook Express folder where you miss email folders in the index ' 2. Moved the folders.dbx of your current Outlook Express folder to a separate backup location (different one as 1.) ' 3. Started OE again to have it rebuild the folders.dbx including all folders, but without a hierarchy ' 4. Copied the new folders.dbx to a separate backup location (different from 1. and 2.) ' 5. Imported all folders from the OE backup location into OE again (now having tons of duplicates) ' ' This script detects which files are missing in the folder structure pf your backup copy of OE. ' How does it do that? ' New files were created by the import of your old OE backup into the new Outlook Express with the flat folder hierarchy. ' OE is not smart to realize that the folder it tries to import and exists with the same name already, is identical to the imported folder ' and simply creates a new folder with the same name, but a different file name than the original folder. For example. ' If you have a folder with the name "My Email Archive", a file exists in OE called "My Email Archive.dbx". ' If you create a new folder with the same name, it cannot use the name "My Email Archive.dbx" anymore, ' because it is already taken by the other folder with that same name. OE creates a new file and simply calls it "My Email Archive (1).dbx". ' And if that exists also, then it creates "My Email Archive (2).dbx" etc. ' Since the imported emails only included the folders that are indexed in the folders.dbx and the backup copy does not include all ' folders, no new folders were created for those that are missing. '--------------------------------------------------------------------------------------------- 'The default location of your OE files, leave it DEFAULT, if you want the script to get the path automatically based on the 'setting for the last used IDENTITY for the currently logged-in user account sFolder = "DEFAULT" 'The location of the OE files backup. If you used the same location as I recommended, then you do not need to change anything sBakFolder = "C:\OEBackup\Files" 'Filename of the text file with the results. You should leave it as it is. sResults = "oefldcompresults.txt" '--------------------------------------------------------------------------------------------- Set fso = CreateObject("Scripting.FileSystemObject") if sFolder = "DEFAULT" then sFolder = defaultoe() end if Dim aSrcFiles() Dim aBakFiles() Dim num1, num2 num1 = 0 num2 = 0 Set ofile = fso.CreateTextFile(sResults, 1) Set Fldr = fso.GetFolder(sFolder) For Each File In Fldr.Files if lcase(right(File.name,4)) = ".dbx" then num1 = num1 + 1 Redim preserve aSrcFiles(num1) aSrcFiles(num1) = left(File.Name,Len(File.Name)-4) end if Next Set Fldr = Nothing Set Fldr = fso.GetFolder(sBakFolder) For Each File In Fldr.Files if lcase(right(File.name,4)) = ".dbx" then num2 = num2 + 1 Redim preserve aBakFiles(num2) aBakFiles(num2) = left(File.Name,Len(File.Name)-4) end if Next For a = 1 to num1 sFile = aSrcFiles(a) bfound = false bfound = Lookup(sFile) if bfound = false then if right(sFile,1) = ")" and instrrev(sFile, "(", -1,1) <> 0 then num = mid(sFile, instrrev(sFile, "(", -1,1)+1, len(sFIle)-instrrev(sFile, "(", -1,1)-1) if isNumeric(num) then if int(num) = 1 then sCheckFileName = left(sFile,len(sFile)-len(num)-3) else sCheckFileName = left(sFile,len(sFile)-len(num)-3) & " (" & num-1 & ")" end if if fso.FileExists(sFolder & "\" & sCheckFileName & ".dbx") and fso.FileExists(sBakFolder & "\" & sCheckFileName & ".dbx") then call clearfile(sCheckFileName) end if end if end if end if Next for x = 1 to num2 if aBakFiles(x) <> "" then ofile.WriteLine sBakFolder & "\" & aBakFiles(x) & ".dbx" end if next ofile.close Set fso = Nothing WScript.echo "check file " & sResults & " for files to keep in the Outlook Express backup directory" WScript.Quit '--------------------------------------------------------------------------------------------- function LookUp(sLookFile) bres = false for b = 1 to num2 if aBakFiles(num2) = sLookFile then bres = true exit for end if next Lookup = bres End Function '--------------------------------------------------------------------------------------------- Sub ClearFile(sClrFile) for x = 1 to num2 if aBakFiles(x) = sClrFile then aBakFiles(x) = "" exit for end if next End Sub '--------------------------------------------------------------------------------------------- function defaultoe() Dim WshShell, IdentityName, IdentityGUID Dim sDirLookup, sDirLoc, sMsg Set WshShell = WScript.CreateObject("Wscript.Shell") IdentityName = WshShell.RegRead("HKCU\Identities\Last Username") IdentityGUID = WshShell.RegRead("HKCU\Identities\Last User ID") sDirLookup = "HKCU\Identities\" & IdentityGUID & "\Software\Microsoft\Outlook Express\5.0\Store Root" defaultoe = WshShell.RegRead(sDirLookup) Set WshShell = Nothing End function