DBXanalyzer Home DBXcmd Command-Line Utility

DBXanalyzer ships with a separate utility DBXcmdTM that can be called via the command line (i.e. in MS-DOS mode).

You can use DBXcmd to create a list of messages in a variety of formats, including CSV, or export the messages in EML (TXT) format to a target directory. You can call the utility from a batch file or have the Windows Scheduler run the batch file every night, for example, to backup certain messages from your DBX files.

Just released
New Improved Upgrade: New release Version 1.2 on 17 February 2009.



To see the syntax and the complete list of options type

dbxcmd -* | more

Quick Syntax

Usage: DBXCMD [-l|-e|-*] [options] dbxfile [outpath]
For full help type DBXCMD -*

See Full Syntax below for the full details.


dbxcmd -l "C:\EmailData\inbox.dbx"
will list all messages in the DBX file inbox.dbx in the folder C:\EmailData on the console with a complete set of tab-delimited fields. Note the option is a lower-case letter L for List.
dbxcmd "C:\EmailData\inbox.dbx"
will do the same as the previous example because -l (list) is the default option.
dbxcmd -e "C:\EmailData\inbox.dbx"
will export all messages in the DBX file to the current working directory as .EML files. You will be prompted before any existing files are overwritten. The output files will have names of the form "Re_ The Subject Line" i.e. the subject line with any illegal filename characters replaced by "_", possibly with "{1}" appended if the same name already exists in the current set. (Hint: Add the -g option to guarantee not to overwrite an existing file of the same name.)
dbxcmd -e "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will do the same but to the output directory C:\mybackup\emails.
dbxcmd -e -y "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will do the same but will overwrite any existing files of the same name without prompting.
dbxcmd -e -g "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will do the same but guarantees to create unique filenames and not overwrite any existing files in C:\mybackup\emails.
dbxcmd -e -pw "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will export all messages with filenames in the format 20041231235959_ReTheSubjectLine, i.e. with a prepended date-time of receipt and all white space and punctuation characters in the subject line removed.
dbxcmd -e -j "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will export all messages with filenames in the format 20041231235959, i.e. with just the date-time of receipt.
dbxcmd -e -a2004-12-31 "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will export all messages received on or after 31 December 2004.
dbxcmd -e -b2005-01-15 "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will export all messages received on or before 15 January 2005.
dbxcmd -e -a2004-12-31 -b2005-01-15 "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will export all messages received between 31 December 2004 and 15 January 2005 inclusive.
dbxcmd -e -a#10 "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
will export all messages received on or after ten days ago based on the system clock and local time.
dbxcmd -e -a#0 "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
ditto but just for today.
dbxcmd -e -xTXT "C:\EmailData\inbox.dbx" "C:\mybackup\emails"
exports all messages with a file extension of .TXT instead of .EML.
dbxcmd -l "C:\EmailData\inbox.dbx" "C:\mylists\inbox_list.txt"
will create a list file C:\mylists\inbox_list.txt in tab-delimited format.
dbxcmd -l -c "C:\EmailData\inbox.dbx" "C:\mylists\inbox_list.csv"
will create a list file C:\mylists\inbox_list.csv in CSV format - this format can be read directly by Microsoft Excel.
dbxcmd -l -ch "C:\EmailData\inbox.dbx" "C:\mylists\inbox_list.csv"
ditto with a header line.
dbxcmd -l -ch -a#0 "C:\EmailData\inbox.dbx" "C:\mylists\inbox_list.csv"
ditto but only list messages received today (i.e. on or after zero days ago).
dbxcmd -l "-s|" "C:\EmailData\inbox.dbx" "C:\mylists\inbox_list.txt"
will create a list file with fields separated by the vertical line character "|". Note the quotes around the option.
dbxcmd -l -ufedm "C:\EmailData\inbox.dbx" "C:\mylists\inbox_list.txt"
will create a list file with only the columns: From, sender's Email address, Date received, and Message ID.

Using in a Batch File - Number 1

Create a batch file called, say, dbxbackup.bat with this one line in it:-

FOR %%f IN ("C:\Email Data\*.dbx") DO dbxcmd -e -g -pw -a#0 "%%f" "C:\mybackup\emails"

This batch file will create a backup of all messages received today in all DBX files in the directory C:\Email Data as unique EML files in the directory C:\mybackup\emails. Note the use of the double "%%" in batch files for variables. You could use Windows Scheduler to run this batch file at, say, 11:55 p.m. each day.

This procedure has the disadvantage that it will miss a whole day's messages if for some reason the batch file doesn't run on time. You may find the batch file below even more useful.

Explanation of options in this example

-e Export messages
-g with Guaranteed unique filenames in output directory
-pw with date-time received Prepended to output filename and all Whitespace and punctuation characters stripped from the subject line
-a#0 received on or After zero days ago, i.e. today in system local time

Using in a Batch File - Number 2

We added the -k option to DBXcmd because we wanted to do a better backup of our emails every night. The -k option creates a filename based on a unique checksum of the file. This enables you to keep backing up your inbox to the same output directory and ensures that only new messages get backed up.

The following batch file emailbackup.bat runs every night on our XP system at 11:40 p.m. It uses the -kjy options to back up every message in Inbox and Sent Items since the first of the month. The same message will always have exactly the same filename, so you don't end up duplicating messages. The -m option causes a new output directory to be created; -d turns off unnecessary output; and the -a option backs up all messages dated on or after the first of the current month.

Just be aware that the batch file below assumes a UK-style date in the form "dd/mm/yyyy". You will need to change it if using in the USA or Japan.

@echo off
:: NOTE: this assumes the UK-style date, e.g. "Sun 15/02/2009"
:: with the year starting at posn 10 and the month at 7.
:: Form dir name from date in form yyyymm, e.g. "200902"
set THISYM=%DATE:~10,4%%DATE:~7,2%
:: and ISOdate in form yyyy-mm-dd at first of month, e.g. "2009-02-01"
set THISISODATE=%DATE:~10,4%-%DATE:~7,2%-01

:: Creates a subdir eg 200902_Inbox containing all the .eml msgs from Inbox.dbx
:: dated on or after the first of the month;
:: Zips the contents into 200902_Inbox.zip,
:: Then removes the 200902_Inbox dir

set THISBOX=Inbox
echo Backing up emails in %THISBOX% to %THISREF%...
dbxcmd -e -kjy -md -a%THISISODATE% "C:\EmailData\%THISBOX%.dbx" "%THISREF%"
zip -ujq "%THISREF%.zip" "%THISREF%\*.*"
DEL "%THISREF%"\*.eml

set THISBOX=Sent Items
echo Backing up emails in %THISBOX% to %THISREF%...
dbxcmd -e -kjy -md -a%THISISODATE% "C:\EmailData\%THISBOX%.dbx" "%THISREF%"
zip -ujq "%THISREF%.zip" "%THISREF%\*.*"
DEL "%THISREF%"\*.eml

This also uses the free GNU zip.exe program to compress the files. The end result is a set of zip files:

200901_Sent Items.zip
200902_Sent Items.zip

a pair for each month with the latest set being updated every night. Each message received or sent during the month will exist in the zip file with a name based on the date and time received together with a 32-bit checksum of the message file itself.

Zip file

This might look a bit wierd, but, trust us, it works a treat. if you ever need to restore a complete month of emails back into OE, just drag and drop the whole lot into your Inbox window.

Full Syntax

This is DBXCMD Licensed Version 1.2.0 (Feb 17 2009)
Copyright (C) 2005-9 DI Management Services Pty Ltd <www.di-mgt.com.au>
Usage: DBXCMD [-l|-e|-*] [options] dbxfile [outpath]
-l List messages to file <outpath> (default=console)
-e Export message files to directory <outpath> (default=CWD)
-* Display help and quit
GENERAL options:
-y suppress prompting before overwriting a file
-d Dumb mode ie no output except errors
-- subsequent parameters are not options
FILTER options on messages to be listed/exported:
-a<date> on or After date yyyy-mm-dd, eg -a2004-12-31
-b<date> on or Before date
-o<date> On the specified date
-a#<n> on or After <n> days ago, eg -a#10
-b#<n> on or Before <n> days ago
-o#<n> On the day <n> days ago
OUTPUT FILENAME options for export/listing:
-x<ext> use <ext> as file eXtension (default=EML) eg -xTXT
-k add checKsum to filename (best used with -kpwy and NOT -g)
-p Prepend date-time received to output filename
-j Just use date-time with no subject for output filename
-w remove Whitespace and other punctuation characters from filename
EXPORT options:
-m Make new directory without prompting
-g Guarantee not to overwrite existing file (adds {1} to name)
LIST options:
-h include Header as first line (default=no header)
-c output in CSV format (default=tab delimited)
-s<char> use <char> as field Separator (default tab) eg -s;
-q Quote strings with quotation marks (default no quote)
-u<colcodes> list colUmns as per column codes (see below)
-u* = list all columns in default order (default)
COLUMN CODES in default order:
i Index number
f From name
s Subject
a Attachments Y/N
d Date received
k size in KB
p Priority
r to Recipient
t sent To
v account serVer
m MessageID
o Output filename
z filesiZe in bytes
e sender Email address
c reCipient email address
  eg -uefs lists columns (senderEmail,From,Subject)
1. Specify dates in ISO format yyyy-mm-dd
2. Quote parameters with `special' chars eg "-s|"
   and with spaces eg "C:\My Documents"
For more info see <http://www.di-mgt.com.au/dbxanalyzer/dbxcmd.html>
To see this help again more slowly, type DBXCMD -* | more



Any comments, feedback, questions to our email or use our Contact Page.

This page last updated: 31 May 2014

Valid HTML 4.01 Strict Valid CSS