Skip to content

Export theBat to Outlook

2011/06/13

I’m working on a migration of mails from theBat to Outlook 2010. Because I have multiple accounts configured in theBAT and many folders in each account I’m to lazy to use theBat export function manual.

Following powershell script enumerates all folders in theBat and starts it with an export command for each of them. I assume that 5 seconds are enough for theBat to do the export. After this time I kill the process and continue with the next folder. All emails are exported as .msg files in standard RFC-822 format:

You must change the settings to reflect your installation.

“C:\Programme\The Bat!” is the location where the binaries are installed

$mbxfolderroot is the path where theBat stores the data of the mail accounts. I used a second disc. If I need to reformat the c: drive my data won’t be lost

$exportroot is a new empty folder where the exported mails shall be stored

function make-export { 
    param ($folder)
    
    $source = join-path $mbxfolderroot $folder
    if ( (test-path "$source\MESSAGES.TBB") ) {
        $target = join-path $exportroot $folder 
        new-item $target -itemtype directory -Force | out-null
        $thebatcommand = @'
/NOLOGO /exportF="\\{0}";o="{1}";
'@
$thebatcommand = $thebatcommand -f $folder,$target          
        Start-Process -FilePath "C:\Programme\The Bat!\thebat.exe" -ArgumentList $thebatcommand -WorkingDirectory "C:\Programme\The Bat!"
        sleep 5
        get-process -name "thebat" | stop-process
         
    }
    get-childitem $source | ?{$_.psiscontainer} | %{ make-exportSpruch "$($folder)\$($_.name)"}

}

$mbxfolderroot ="D:\my_documents\my_batMailboxes"
$exportroot = "D:\_thebat_export"

$accountfolders = get-childitem $mbxfolderroot | ?{$_.Psiscontainer}| select name
$accountfolders | ?{$_.name -ne "trash"  -and $_.name -ne "Attach"} | %{make-export  $_.name}

 

The folders trash and attachments are excluded. Each folder in the $mbxfolderRoot is the directory of one account. The make-export function recursively crawls through the folder structure on disk which is a mirror of the folders in theBat. The bat leaves some empty folders on disk when folders are moved in the mail program. That is why only for that folders which include a message.tbb file are exported. They are candidates to contain mails.

 

Story continues as soon as I know how to import the mails. The next thing is to create al the mail accounts in Outlook. I think doing this manual is faster than trying to write an export of the settings.

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: