The Bat! Help

Folders (6)
Macros (13)
Backup (4)

Additional Information

  • Command Line Parameters
  • Regular Expressions
  • Uninstalling the Program

  • Command Line Parameters

    /CHECK and /CHECKALL
    /SEND and /SENDALL
    /IMPORT
    /EXPORT
    /FOCUS
    /MAIL
    mailto:
    /ADD
    /OP
    /DEDUPIGNOREMSGID, /DEDUPIGNORETOMSGID, /DEDUPIGNORETO and /DEDUPIGNOREDATE
    /BATCH
    /LDIFIMPORT and /LDIFEXPORT
    /REFILTER
    /MINIMIZE, /MIN, /EXIT, /SMARTEXIT, /NOLOGO and others

    What is a Command Line


    The command line is a text string that is passed to the system whenever a program is executed. It contains the path to the program, followed by a set of parameters. To start a program in Windows, you can either use the Start menu "Run" command, or click on the program’s shortcut on the desktop or in the Start menu. If you start a program by clicking its shortcut, you can edit the command line in the properties of this shortcut. Right-click the shortcut, select “Properties” and under “Shortcut” change the command line in the “Target” field.

    For The Bat!, the command line in a Shortcut looks like this:

    "C:\Program Files (x86)\The Bat!\thebat32.exe" or "C:\Program Files\The Bat!\thebat64.exe"

    You can add some start-up parameters to the command line to define a set of actions performed whenever you start the program. For example, you can switch off the The Bat! start-up logo by adding the /NOLOGO parameter:

    "C:\Program Files (x86)\The Bat!\thebat32.exe" /NOLOGO



    Using The Bat! command line parameters from batch files and other programs


    It is possible to use The Bat! from batch files or other programs meaning that you are able to automatically send and receive emails.

    For example, to send two email messages, run the following sequence of commands from a batch file, provided that the current directory is "C:\Program Files\The Bat!\thebat64.exe":

    thebat64.exe /MAILTO=recipient1@ritlabs.com;SUBJECT=Test;TEXT=c:\test\test1.txt
    thebat64.exe /MAILTO=recipient2@ritlabs.com;SUBJECT=Test;TEXT=c:\test\test2.txt

    This example demonstrates using the /MAIL command line parameter for automated message creation.

    Following is the description of all command line parameters that The Bat! supports.

    Checking Mail - /CHECK and /CHECKALL


    /CHECK can be used as a command line parameter whenever you want to check mail for one or more accounts.

    /CHECKALL is used for checking mail for all accounts and exiting from The Bat! if there were no new messages received. It is a simplified form of the /CHECK* /SMARTEXIT combination.

    Syntax


    /CHECK<account mask1>[;account mask2[;account mask3[...]]]

    The account mask is used to identify which accounts to perform the check operation for. It can be:
    Note: To separate account masks, use semicolons (";" character). Do not use spaces between account masks, because a space-separated mask will be interpreted as the start of the next command line parameter and will not be processed as intended.

    If a mask contains space characters, enclose it in quotation marks. If a mask contains quotation marks, you should use single quotes (" ' " character).


    • Account name. Example: /CHECK"Account 1";"Account 2". Thus, The Bat! will check new mail for the accounts “Account 1” and "Account 2" (note that quotation marks are not included into account names - they are used only because the names contain space characters)
    • The beginning of an account name ending with an asterisk (* sign). Example: to check new mail for all accounts with names starting with the word "My", use /CHECKmy*
    • Asterisk followed by the end of an account name. Example: /CHECK*1 will check new mail for all accounts with names ending with "1"
    • A name fragment surrounded by asterisks. Example: /CHECK*account* will check all accounts with the word "account" in their name
    • An asterisk, which means that all accounts will be checked

    Sending Mail - /SEND and /SENDALL


    The /SEND command can be used as a command line parameter for The Bat!, whenever you want to send all queued mail from one or more accounts.

    The /SENDALL command is used for sending queued mail from all accounts and exiting from The Bat!, if there were no queued messages. It is a simplified form of the /SEND* /SMARTEXIT combination.

    Syntax

    /SEND<account mask1>[;account mask2[;account mask3[...]]]

    The account mask is used to identify the accounts to perform the send operation for. It can be:
    • Account name. Example: /SEND"Account 1";"Account 2". The Bat! will send queued mail from the accounts “Account 1” and “Account 2” (note that quotation marks are not included into account names - they are used only because the names contain space characters)
    • The beginning of an account name ending with an asterisk (* sign). Example: to send queued mail from all accounts with names starting with the word "My", use /SENDmy*
    • Asterisk followed by the end of an account name. Example: /SEND*1 will send queued mail from all accounts with names ending with "1"
    • A name fragment surrounded by asterisks. Example: /SEND*account* to send mail from all accounts with the word "account" in their name
    • An asterisk which means that queued mail will be sent from all accounts

    Importing Messages - /IMPORT


    The /IMPORT command allows to import messages to a specified folder from RFC-822 message files or from UNIX mailbox files.

    Syntax

    /IMPORT[parameter1[;parameter2[;parameter3[...]]]

    Possible Parameters

    ParameterDescription
    USER=value or U=valueAccount name. If no FOLDER parameter is specified, the destination folder will be the Inbox of the given account
    PASSWORD=value or P=valueThe password which will unlock the account if it is needed
    FOLDER=value or F=valueThe pathname of the destination folder. If the pathname does not include an account name, The Bat! will search all accounts for a folder with a matching name. If the specified folder is not found, the Inbox folder of the destination account is used
    UNIX or XThis parameter tells The Bat! that the input files are in UNIX mailbox format. By default, input files are treated as separate RFC-822 messages
    READ or RWhen this parameter is used, all imported messages will be marked as read (by default, all imported messages are marked as unread)
    FILE=value or IN=value or INFILE=value or I=valueA file mask with the pathname for the input files. The /IMPORT command can have an unlimited number of such parameters
    DELETE or DEL or WIf this parameter is specified, all files processed will be deleted once they have been successfully imported

    Examples

    /IMPORTU="Account 1";FOLDER="Friends\Sam";IN=C:\Inbox\Sam\*.MSG
    /IMPORTF="\\Account 1\Business\Unsorted";UNIX;FILE=C:\Inbox\Unsorted\*.mbox;READ


    Exporting Messages and Addresses - /EXPORT


    The /EXPORT command allows to export messages from a specified folder to RFC-822 message files or UNIX mailbox files. This command also allows the export of address book entries if the LDIF parameter is specified.

    Syntax

    /EXPORT[parameter1[;parameter2[;parameter3[...]]]

    Possible parameters

    ParameterDescription
    USER=value or U=value Account name. If no FOLDER parameter is specified, the destination folder will be the Inbox of the given account
    PASSWORD=value or P=value The password which will unlock the account if it is needed
    FOLDER=value or F=value The pathname of the source folder. If the pathname does not include an account name, The Bat! will search all accounts for a folder with a matching name. If the specified folder is not found, the Inbox folder of the source account is used
    DIR=value or D=value or OUT=value or O=value The pathname for the output directory (for RFC-882 messages) or for the output path and file name (for UNIX mailbox). If RFC-822 format is chosen, the exported messages are stored in the output directory in files sequentially named xxxxxxxx.MSG (each "x" character corresponds to a digit from 0 to 9). When the export starts, The Bat! calculates the starting xxxxxxxx number and, in the the event when such files are found, the output file names will begin immediately after the greatest number found
    UNIX or XThis parameter tells The Bat! that the output file will be in UNIX mailbox format (by default, output files are in RFC-822 message format)
    READ or RWhen this parameter is used, only read messages are exported. By default, all messages are exported
    UNREAD or NWhen this parameter is used, only unread messages are exported
    REPLIED or REWhen this parameter is used, only replied messages are exported
    UNREPLIED or NRWhen this parameter is used, only non-replied messages are exported
    PARKED or PRWhen this parameter is used, only parked messages are exported
    UNPARKED or UPWhen this parameter is used, only non-parked messages are exported
    MAXAGE=value or AGE=value or A=value Specifies the maximum age (in days) of messages to be exported. If the age of a message exceeds the specified maximum age, the message will not be exported
    START=value or S=value Specifies the number of the starting message in the source folder. All messages located before the starting message will not be exported. If a negative value is given, the starting message number is calculated by subtracting the positive value from the number of messages in a folder, for example, if -5 is specified, that means that the export will start from the fifth message from the end of the message base
    END=value or E=value Specifies the number of the final message in the source folder for the export operation. All messages located after this final message will not be exported. If a negative value is given, the last message number is calculated by subtracting the positive value from the number of messages in the folder, for example, if a value of -2 is given, this means that the export will end at the second message from the end of the message base
    OVERRIDE or VIf this parameter is specified (used with UNIX or LDIF parameters), The Bat! will overwrite the output file if it already exists. By default, The Bat! adds new messages to the end of the mailbox file
    DELETE or DEL or WAll messages processed will be deleted at the end of a successful export operation
    LDIFIf this parameter is specified, an address export in LDIF will be performed
    ADDRESSBOOK=value or AB=value or BOOK=value A name, filename or the full path of the address book which should be exported (used with the LDIF parameter). If no address book is specified, The Bat! uses the default address book
    GROUP=value or G=value The handle of the address book group which should be exported (used with the LDIF parameter). If no address book is specified, The Bat! will search all address books for the first group whose name matches the specified handle

    Examples

    /EXPORTU="Account 1";F="Friends\Sam";DIR=C:\Inbox\Sam\;S=-20
    /EXPORTF="\\Account 1\\Unsorted";UNIX;O=C:\Unsorted\Mail.mbx;UNREAD
    /EXPORTLDIF;AB="Address book 1";Group="My group";O="C:\MyGroupFile.LDIF"
    /EXPORTLDIF;Group="Friends";O="C:\Friends.LDIF"


    Focusing on a Folder - /FOCUS


    The /FOCUS command allows you to automatically focus on a specified folder in the main window.

    Syntax

    /FOCUS[parameter1[;parameter2[;parameter3[...]]]

    Possible Parameters - (a parameter may be identified by two or more names):

    ParameterDescription
    USER=value or U=value The name of the source account. If no FOLDER parameter is specified, the target folder will be the Inbox of the given account
    PASSWORD=value or P=value The password which will unlock the account if it is needed
    FOLDER=value or F=value The pathname of target folder. If the pathname does not include an account name, The Bat! will search all accounts for a folder with a matching name. If the specified folder is not found, the Inbox folder of the target account is used

    Examples

    /FOCUSU="Account 1";F="Friends\Sam"
    /FocusF="\\My account\New mail";P=mypass

    Automated Message Creation - /MAIL


    The /MAIL command is used for automated message creation using a template, text file and attachments for a specified address.

    Syntax

    /MAIL[parameter1[;parameter2[;parameter3[...]]]

    ParameterDescription
    USER=value or U=value Account name. If no FOLDER parameter is specified, the target folder will be the Outbox of the given account
    PASSWORD=value or P=value Access password for this account if needed
    FOLDER=value or F=value The pathname of the target folder. If the pathname does not include an account name, The Bat! will search all accounts for a folder with a matching name. If the specified folder is not found, the Outbox folder of the target account is used
    TEMPLATE=value or T=value The pathname of the file which contains the template that will be used for this message. The standard template of the target folder or account is used by default
    TO=value First recipient’s email address. You can add additional recipients using the %TO, %CC or %BCC macros in the template
    SUBJECT=value or S=value Message subject. You can specify the subject using the %SUBJECT macro in the template
    TEXT=value or CONTENTS=value or C=value The pathname of a plain text file which contains the text of the message. It is also possible to include a text file into a message using the %PUT macro in the template
    ATTACH=value or FILE=value or A=value The pathname of the file which will be attached to the message. It is also possible to use the %ATTACHFILE macro in the template to attach a file
    SENDIf this parameter is used, the created message will be sent as soon as it has been created
    QUEUEIf this parameter is used, the created message will be queued in the Outbox folder once it is created
    EDITIf this parameter is used, The Bat! opens the editor with the message created using the specified parameters

    Examples

    /MAILU=MyAccount;TO=john.doe@ritlabs.com;S=Test;TEXT=C:\TEST\TEST.MSG
    /MAILF=\\MyAccount\Test;TO=john.doe@ritlabs.com


    Message Creation - mailto:


    The mailto: command is used to open a new editor window in The Bat! using pre-set parameters.

    mailto: is the standard Internet URL for publishing email addresses which is described in RFC 2368. This command line parameter can be used by browsers that need to open an email editor when the user clicks on a link which contains a mailto: URL.


    Creating New Account –/ADD


    The /ADD command allows to create new accounts. All parameters correspond to account settings.

    Syntax

    /ADD:[parameter1 [;parameter2 [;parameter3 [...]]]

    ParameterDescription
    User=valueAccount name
    InServer=valueThe incoming mail server address (POP3 or IMAP4)
    OutServer=valueThe outgoing mail server address (SMTP)
    InUser=valueUser name at the incoming mail server
    InPassword=valuePassword to access the mailbox
    OutUser=valueUser name at the outgoing mail server (if it differs from the user name specified for the incoming mail server)
    OutPassword=valuePassword at the outgoing mail server (if it differs from the user name specified for the incoming mail server)
    TLS or IMAPTLS or POPTLSSets the “Secure to dedicated port (TLS)” connection type for POP/IMAP (regular connection type is used by default)
    SendTLS or SMTPTLSSets the „Secure to dedicated port (TLS)” connection type for SMTP (regular connection type is used by default)
    StartTLS or IMAPStartTLS or POPStartTLSSets the “Secure to regular port (STARTTLS)” connection type for POP/IMAP (regular connection type is used by default)
    SendStartTLS or SMTPStartTLSSets the „Secure to regular port (STARTTLS)” connection type for SMTP (regular connection type is used by default)
    REGULARSets the regular connection type for POP/IMAP
    SMTPREGULARSets the regular connection type for SMTP
    NOSMTPAUTHDisables SMTP Authentication (RFC 2554) (SMTP Authentication is enabled by default)
    SMTPAUTHEnables SMTP Authentication (RFC 2554) if it was disabled
    CombinedEnables the “combined delivery (send+receive)” option
    DeferredSets the deferred delivery type
    IMAPSets the IMAP4 protocol for this account, otherwise the POP3 protocol will be used
    FileDir[="attachment directory"]Enables the “Keep attachment files separately in a special directory” option. If the directory is not specified, the program uses the default directory to keep attachments
    Template="value"The default new message template for this account stored in a file
    ReplyTemplate="value"The default reply template for this account stored in a file
    ForwardTemplate="value"The default forward template for this account stored in a file
    KeepDays=valueThe period during which messages will be kept on the server
    DelReceivedEnables the “Delete received messages from server” option. By default, messages are left on the server
    DelTrashServerEnables the “Delete message from server when it is removed from Trash” option
    SizeLimit=valueThe maximum size of a message in Kbytes
    FromAddr=valueThe From email address
    FromName=valueThe From name
    ReplyAddr=valueThe Reply-To email address
    ReplyName=valueThe Reply-To name
    PortPOP=valuePort number for POP (if it is non-standard)
    PortSMTP=valuePort number for SMTP(if it is non-standard)
    PortIMAP=valuePort number for IMAP (if it is non-standard)
    Password=valueThe password which unlocks the account if it is needed

    Example (write in a single line without space characters)
    /ADD; User="john"; InServer="pop3.example.com"; OutServer="smtp.example.com"; InUser="john"; InPassword="johnpass"; FromAddr="john.doe@ritlabs.com"; FromName="John Doe"; ReplyAddr="john.doe@ritlabs.com"; ReplyName="John Doe"


    Folder Maintenance - /OP


    The /OP command is used to carry out folder maintenance.

    Syntax

    /OP:<parameter1>:<parameter2>:<argument>

    Possible parameters

    ParameterDescription
    COMPRESSCompacts a folder
    PURGEPurges old/exceeding messages
    KILLDUPESRemoves duplicates
    CLEARCACHEClears cache
    EMPTYEmpties a folder

    Possible arguments

    ArgumentDescription
    ACCOUNT NAMEAccount name
    FULL PATH TO FOLDERFull path to the specified folder

    Examples

    /OP:COMPRESS:Andrew
    /OP:KILLDUPES:PURGE:COMPRESS:"\\My Account\Inbox"

    Note: You can use several parameters, but only one argument.

    Deleting Duplicates – /DEDUPIGNOREMSGID, /DEDUPIGNORETOMSGID, /DEDUPIGNORETO and /DEDUPIGNOREDATE


    /DEDUPIGNOREMSGID, /DEDUPIGNORETOMSGID, /DEDUPIGNORETO and /DEDUPIGNOREDATE are independent parameters that can be used for removing duplicates.

    By default, duplicates share the same Message-ID, sender (From), recipient (To) and date (Date). Messages are considered duplicates if these four attributes coincide, the other attributes are not taken into account. If two messages have different message bodies, however Message-ID, From, To and Date fields coincide, the program will delete one of these messages if you use the “remove duplicates” command.

    If messages do not have Message-IDs, the program checks the subjects (Subject) instead.

    If you use the /DEDUPIGNOREMSGID parameter, Message-ID is not checked, the program checks the From, To, Date and Subject fields.

    If the /DEDUPIGNORETOMSGID parameter is used, both Message-ID and recipient’s address are not checked, meaning that the program compares only sender’s address, date and subject. If the Date header is missing, the program checks the Received date.

    Use the /DEDUPIGNORETO parameter to check for duplicates by Message-ID, sender and date while ignoring the recipient.

    By executing the /DEDUPIGNOREDATE parameter the program will ignore messages' creation date and look for the duplicates with equal Message-ID, sender and recipient.


    Execution of Several Commands from a File - /BATCH


    /BATCH allows executing multiple commands defined in a text file (each command being placed in one line).

    Syntax

    /BATCH:<filepath>

    For example, if you want to check your account and send queued mail from it, you can create a batch file C:\The Bat!\CheckMail.BAT which contains the following lines:

    /CHECKMyAccount
    /SENDMyAccount
    /SMARTEXIT

    To execute this batch file from a command line, you can run The Bat! with the command line parameter /BATCH:“C:\The Bat!\CheckMail.BAT”


    Exporting and Importing Address Book or Group in LDIF-file –/LDIFIMPORT and /LDIFEXPORT


    Syntax

    /ldifexport:[parameter1[:parameter2[:parameter3[...]]]
    /ldifimport:[parameter1[:parameter2[:parameter3[...]]]

    ParameterDescription
    AB, B, BOOK, ADDRBOOK, ADDRESSBOOK = address book nameThe name of the address book that should be exported or imported
    G, AG, GROUP = group nameThe name of the address book group that should be exported or imported
    FILE = file nameThe name of the file for export or import
    OUT = file nameThe name of the file for export (used instead of FILE)
    IN = file nameThe name of the file for import (used instead of FILE)

    Examples

    thebat32.exe /lidfexport:ab="Main book":file="c:\exported\main.ldif"
    thebat64.exe /lidfimport:ab="Imported":in="c:\exported\main.ldif"

    You can additionally use the /LDIFNOUTF command to disable UTF-8 encoding.


    Sorting Messages –/REFILTER


    The /REFILTER command is used for re-filtering a folder.

    Syntax

    /REFILTER[parameter1[;parameter2[;parameter3[...]]]

    ParameterDescription
    FOLDER=value or F=valueThe pathname of the folder that will be re-filtered
    INCOMING or INIf this parameter is used, the program uses filters for Incoming mail to re-filter the folder
    OUTGOING or OUTIf this parameter is used, the program uses filters for Outgoing mail to re-filter the folder
    READ or RDIf this parameter is used, the program uses filters for Read messages to re-filter the folder
    REPLIED or RPIf this parameter is used, the program uses filters for Replied messages to re-filter the folder
    MANUALONLY or MANUALIf this parameter is used, the program uses manual filters only

    Example

    /REFILTER;F="\\Account\My Folder";IN;REPLIED


    Other commands - /MINIMIZE, /MIN, /EXIT, /SMARTEXIT, /NOLOGO and other


    /EXIT
    The /EXIT command is used to close The Bat! as soon as all mail transfer operations are complete.

    /SMARTEXIT
    The /SMARTEXIT command is used to close The Bat! as soon as all mail transfer operations are complete, but only if no new messages were received.

    /MINIMIZE
    The /MINIMIZE command minimizes The Bat! to the Task Bar or to the System Tray if the respective option under Options -> Preferences -> General is enabled.

    /MIN
    The /MIN command minimizes The Bat! to the Task Bar or to the System Tray if the respective option under Options -> Preferences -> General is enabled.

    /NOLOGO
    The /NOLOGO command disables the start-up screen that appears on program’s start-up. When it is used in the command line, The Bat! logo will not be displayed while program is loading its data.

    /OPEN
    Using the /OPEN command you can open a message or a vCard from a file (VCF/MSG/EML) in a separate window.

    Syntax
    /OPEN:file name

    Example: thebat32.exe /OPEN:"c:\My Data\message.eml"

    /MSGID
    Using the /MSGID command you can view the needed message in a separate window. You should indicate the Message-ID of this message.

    Syntax
    /MSGID:Message-ID

    Example: thebat64.exe /msgid:1234567890.20060202085723@mail.com

    If The Bat! does not find the message in the current folder, the program will offer to select a folder for searching. If you know the folder where the message is kept, you can either use the /FOCUS command or indicate its Message-ID and use the FOLDER parameter.

    Examples: thebat32.exe /FocusF="\\\General\ABC Folder"/msgid:1234567890.20060202085723@mail.com
    or thebat32.exe /msgid:1234567890.20060202085723@mail.ru?folder="\\\General\ ABC Folder"

    Note:
    The pathname of a common folder should be specified using the following format: \\\CommonFolder\path\name\folder
    The pathname of a folder should be specified using the following format: \\AccountName\path\name\folder

    /CARDFILE
    The /CARDFILE command allows to send submission forms.

    Syntax
    /CARDFILE"file name"

    /TERMINATE
    The /TERMINATE command closes The Bat! even if there are active sessions in the queue.

    /REG
    Using the /reg:<name> command you can launch The Bat! from different registry key (the name of the key consists of The Bat!+<name>). For example, if you launch The Bat! using the /reg:test parameter, the key The Bat!test will be created in the Registry, and you will be able to set up The Bat! anew.

    /DontWriteEmailEnvironmentVariable
    You can configure The Bat! not to specify the %EMAIL% variable by running it with the /DontWriteEmailEnvironmentVariable command line parameter, or by setting the DWORD DontWriteEmailEnvironmentVariable variable to 1 under HKEY_CURRENT_USER\Software\RIT\The Bat!

    /DECRYPT_FILE_OTFE
    If you add this command line parameter and start The Bat! with the encrypted database, the program will prompt you to select a file from within the mail database, then it will save the decrypted copy of the selected file (adding .decrypted) in the same directory and terminate.


    0  

    Regular Expressions

    Regular expression matching allows you to test whether a string fits a specific syntactic shape. You can also search a text string for a sub-string that fits a pattern. A regular expression describes a set of strings. The simplest case is one that describes a particular string; for example, the string foo when regarded as a regular expression matches foo and nothing else. Non-trivial regular expressions use special constructs with which they can match more than one string. For example, the regular expression foo|bar matches either the string foo or the string bar; the regular expression c[ad]*r matches any of the strings cr, car, cdr, caar, cadddar and all other such strings with any number of a's and d's. The Bat! allows using regular expressions in the message editor, in the message finder, in the sorting office and in the templates.

    Regular Expressions in the Message Editor

    In the message editor, regular expressions can be used to search for sub-strings matching a search pattern. To find a sub-string that matches a regular expression, invoke the search dialog using the Search -> Find menu and type the regular expression, make sure that the "Regular Expression" check box is selected and start the search. Regular expressions can also be used for the Replace function in the Message Editor.

    If a match is found, the text that matches the given regular expression will be marked as selected in the message editor. If the regular expression has sub-patterns, the first captured substring will be selected, i.e. for the regular expression Total amount: *(\S+) only the word following Total amount will be selected but not Total amount itself.

    The default PCRE options for the message editor are PCRE_CASELESS or none for a case sensitive search. Matching is done on a string-by-string basis.


    Regular Expressions in the Message Finder


    You can use regular expressions when you search for messages. Select the "Match" option in the drop-down condition list. The default PCRE options for the message finder are PCRE_CASELESS+PCRE_MULTILINE or PCRE_MULTILINE for a case sensitive search. Matching is done by treating the whole message as a single string. CF/LF pairs (0D/0A) are replaced by single LF (0A) characters before matching.

    Regular Expressions in the Sorting Office


    It is possible to use regular expressions as signal strings in the message filters. In a filter definition in the Sorting Office dialog, choose the "match" condition to make use of "Regular expressions" in the match string. The default PCRE options for message filters are PCRE_CASELESS+PCRE_MULTILINE. Matching is done by treating the whole message as one string. CF/LF pairs (0D/0A) are replaced with single LF (0A) characters before matching.

    Regular Expressions in the Templates


    The Bat! allows for using regular expressions in message templates. The idea is to search some text for the first occurrence of a sub-string matching a pattern defined in a regular expression and then to insert the result of that search right back into the message text. For example, it is possible to parse incoming messages of a particular format and create new messages in another format with extra, modified or removed information. To search the original message text for a sub-string, use the %REGEXPTEXT="regexp" macro where regexp defines the search pattern. The %REGEXPQUOTES="regexp" macro does the same, but returns the result as a quotation.

    When you need to search text for a particular sub-string, use the %SETPATTREGEXP="regexp" and %REGEXPMATCH="string" macro combination. regexp defines the search pattern for all subsequent occurrences of the %REGEXPMATCH macro until the next instance of %SETPATTREGEXP. It is possible to use macros to generate any text you need, e.g. %QUOTES="%SETREGEXP=""regexp""%REGEXPMATCH=""%TEXT""" is equivalent to %REGEXPQUOTES="regexp".

    If a match is found, the text that matches a given regular expression is returned. If the regular expression has subpatterns, the first captured substring is returned, i.e. for the regular expression Total amount: *(\S+) only the word following Total amount will be returned but not Total amount itself. %REGEXPBLINDMATCH="string" is like the %REGEXPMATCH="string" macro except that matched string/substrings are not returned, but may be further extracted using %SUBPATT="n" macros where n is the number of a captured substring; %SUBPATT='0' returns the text matching the entire Regular Expression pattern, 1 is the text of the first matching subpattern, 2 - the second matching subpattern, etc. Thus the %REGEXPBLINDMATCH="string" macro allows you to have more than one subpattern in its results e.g.: %QUOTES="%SETPATTREGEXP=""total_amount +(\S+).*flowers_type +(\S+)""%REGEXPBLINDMATCH=""%TEXT""pay %SUBPATT=""1"" for %SUBPATT=""2"""

    The default PCRE options for templates are PCRE_CASELESS+PCRE_MULTILINE+ PCRE_DOTALL. Matching is done by treating a whole message as one string. CF/LF pairs (0D/0A) are replaced with single LF (0A) characters before matching.



    Regular Expressions Syntax (Basic)


    A regular expression is a set of rules that describes a generalized string. If the characters that make up a particular string conform to the rules of a particular regular expression, the regular expression is said to match that string.

    For example, the regular expression b. matches the strings bovine, above, Bobby, and Bob Jones, but not the strings Bell, b, or Bob. That's because the expression insists that the letter b (lowercase) must be in the string and must be followed immediately by another character.

    The regular expression b+ requires the lowercase letter b at least once. This expression matches b and Bob in addition to the example matches for b. in the preceding paragraph. The regular expression b* requires zero or more bs, so it matches any string. That seems to be fairly useless, but it makes more sense as part of a larger regular expression. Bob*y, for example, matches all of Boy, Boby, and Bobby but not Boboby.

    Assertions

    Assertions are used to anchor parts of the pattern to word or string boundaries. The ^ assertion matches the start of a string, so the regular expression ^fool matches fool and foolhardy but not tomfoolery or April fool. The following table lists the assertions:

    AssertionDescriptionExampleMatchesDoes not match
    ^Start of string^foolfoolishTomfoolery
    $End of stringfool$April foolFoolish
    \bWord boundarybe\bsidebe sideBeside
    \BNon-word boundarybe\Bsidebesidebe side

    Atoms

    The . (period) is an example of a regular-expression atom. Atoms are the fundamental building blocks of a regular expression. A full list of atoms appears in the following table:

    AtomDescriptionExampleMatchesDoes not match
    Period (.)Any character except new lineb.bBobbb
    List of characters in bracketsAny one of those characters^[Bb]Bob, bobRbob
    Regular expression in parenthesesAnything that regular expression matches^a(b.b)c$Abobcabbc

    Quantifiers

    A quantifier is a modifier for an atom. It can be used to specify that a particular atom must appear at least once, as in b+. The atom quantifiers are listed in the following table:

    QuantifierMatchesExampleMatchesDoes not match
    *Zero or more instances of the atomab*cac, abcabb
    +One or more instances of the atomab+cAbcac
    ?Zero or one instance of the atomab?cac, abcabbc
    {n}n instances of the atomab{2}cAbbcabbbc
    {n,}At least n instances of the atomab{2,}cabbc, abbbcabc
    {n,m}At least n, most m instances of the atomab{2,3}cAbbcabbbbcat

    Special Characters

    Several special characters are denoted by backslashed letters:

    SymbolMatchesExampleMatchesDoes not match
    \dAny digitb\ddb4dBad
    \DNon-digitb\Ddbddb4d
    \nNew line 
     
     
    \rCarriage return 
     
     
    \tTab 
     
     
    \fForm feed 
     
     
    \sWhite-space character 
     
     
    \SNon-white-space character 
     
     
    \wAlphanumeric charactera\wba2ba^b
    \WNon-alphanumeric charactera\Wbaa^bAabb

    Backslashed Tokens

    It is essential that regular expressions be capable of using all characters, so that all possible strings can be matched. With so many characters having special meanings, a mechanism is required that allows you to represent any arbitrary character in a regular expression. This mechanism is a backslash (\), followed by a numeric quantity. This quantity can take any of the following formats:

    QuantityDescription
    Single or double digitMatched quantities (backreferences) after a match
    Two- or three-digit octal numberThe character with that number as character code, unless it’s possible to interpret it as a backreference
    x, followed by two hexadecimal digitsThe character with that number as its character code. Example: \x3e matches >
    c, followed by a single character The control character. Example: \cG matches <Ctrl+G>
    Any other character The character itself. Example: \& matches the & character



    0  

    Uninstalling the Program

    To uninstall the program, access the Control Panel, select The Bat! in the list of installed programs and click the "Uninstall" button. Note that your mail data (emails, address books, configuration files, etc.) is not removed when you uninstall The Bat! by clicking "Uninstall". Only the program files are deleted in this case. To remove your mail data, click the "Change" button instead of Uninstall, then select "Remove" and deselect the "Keep the working directory and all data files" check box. This will remove both program files and mail data from your computer. To make sure your mail data is removed, open the "Run" dialog box from the Start menu (Windows+R), type %email% in the "Open" edit box, and click OK. Your mail folder will be opened – it should be empty. If there are still files in this folder, remove them.


    0