counter
List of available Data extraction items (4) in this library
Title Category
[Click to unfilter]
Submitted by Function
Date Translation Data extraction Januk Aggarwal Convert original sender's message date to longer format (can be modified for translation to other languages or formats).
Recipient list Data extraction Januk Aggarwal Reformat list of recipients into a vertical list. Can be modified to list only names or only addresses.
Sender Date Data extraction Allie C Martin Change original sender date format to dd/mm/yyyy
X-Mailer Extractor Data extraction Allie C Martin Extracting X-Mailer headers from Headers

Back to The Bat! FAQ / How-Do-I

Date Translation
[ Data extraction]
Convert original sender's message date to longer format (can be modified for translation to other languages or formats). Added to the Library by Januk Aggarwal

See below for v2 adaptation

=====[ Date ]=====
%COMMENT='%-
%REM="Do the translation of the weekday"%-
%Comment="%-
%-%-%SETPATTREGEXP=_(?im-s)^Date\:.*(Sun|Mon|Tue|Wed|Thu|Fri|Sat)_%-
%-%-%REGEXPMATCH=_%Headers_"%-
%-
%IF:"%Comment"="Sun":"Sunday":""%-
%IF:"%Comment"="Mon":"Monday":""%-
%IF:"%Comment"="Tue":"Tuesday":""%-
%IF:"%Comment"="Wed":"Wednesday":""%-
%IF:"%Comment"="Thu":"Thursday":""%-
%IF:"%Comment"="Fri":"Friday":""%-
%IF:"%Comment"="Sat":"Saturday":""'%-
%-
%IF:'%COMMENT'<>'':'%COMMENT, '%-
%-
%REM="Do Month translation"%-
%Comment="%-
%SETPATTREGEXP='(?im-s)^Date\:.*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'%-
%REGEXPMATCH='%Headers'"%-
%-
%IF:"%Comment"="Jan":"January":""%-
%IF:"%Comment"="Feb":"February":""%-
%IF:"%Comment"="Mar":"March":""%-
%IF:"%Comment"="Apr":"April":""%-
%IF:"%Comment"="May":"May":""%-
%IF:"%Comment"="Jun":"June":""%-
%IF:"%Comment"="Jul":"July":""%-
%IF:"%Comment"="Aug":"August":""%-
%IF:"%Comment"="Sep":"September":""%-
%IF:"%Comment"="Oct":"October":""%-
%IF:"%Comment"="Nov":"November":""%-
%IF:"%Comment"="Dec":"December":"" %-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{1,2})\s"%-
%REGEXPMATCH="%HEADERS", %-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{4})"%-
%REGEXPMATCH="%Headers"%-
%-
%COMMENT=""%-
=====[End QT]=====

**** Version 2 adaptation:

=====[ Date ]=====
%_DayForm='%-
%REM="Do the translation of the weekday"%-
%_Extract="%-
%-%-%SETPATTREGEXP=_(?im-s)^Date\:.*(Sun|Mon|Tue|Wed|Thu|Fri|Sat)_%-
%-%-%REGEXPMATCH=_%Headers_"%-
%-
%IF:"%_Extract"="Sun":"Sunday":""%-
%IF:"%_Extract"="Mon":"Monday":""%-
%IF:"%_Extract"="Tue":"Tuesday":""%-
%IF:"%_Extract"="Wed":"Wednesday":""%-
%IF:"%_Extract"="Thu":"Thursday":""%-
%IF:"%_Extract"="Fri":"Friday":""%-
%IF:"%_Extract"="Sat":"Saturday":""'%-
%-
%IF:'%_DayForm'<>'':'%_DayForm, '%-
%-
%REM="Do Month translation"%-
%_Extract="%-
%SETPATTREGEXP='(?im-s)^Date\:.*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'%-
%REGEXPMATCH='%Headers'"%-
%-
%IF:"%_Extract"="Jan":"January":""%-
%IF:"%_Extract"="Feb":"February":""%-
%IF:"%_Extract"="Mar":"March":""%-
%IF:"%_Extract"="Apr":"April":""%-
%IF:"%_Extract"="May":"May":""%-
%IF:"%_Extract"="Jun":"June":""%-
%IF:"%_Extract"="Jul":"July":""%-
%IF:"%_Extract"="Aug":"August":""%-
%IF:"%_Extract"="Sep":"September":""%-
%IF:"%_Extract"="Oct":"October":""%-
%IF:"%_Extract"="Nov":"November":""%-
%IF:"%_Extract"="Dec":"December":"" %-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{1,2})\s"%-
%REGEXPMATCH="%HEADERS", %-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{4})"%-
%REGEXPMATCH="%Headers"%-
=====[End QT]=====


Recipient list
[ Data extraction]
Reformat list of recipients into a vertical list. Can be modified to list only names or only addresses. Added to the Library by Januk Aggarwal

This is the recursive engine.  Because it uses the %COMMENT macro, it has a
TB V2 variant (listed below). You can feed it any recipient list that ends
with a semi-colon and a space.

=====[Begin recipient2]=====
%REM='
      Recipient List reformating routine.
      recipient2 = recursive engine QT
      
      Written by Januk Aggarwal
      June 2002
      Update: August 2002
'%-
%-
%IF:'%-
%SETPATTREGEXP=$(?i)^((\"?)(.*?)\2\s*(<.*?>)?\s*[;,]\s*)?$%-
%REGEXPMATCH=$%COMMENT$'<>'':'%-
%-
%SETPATTREGEXP=$(?i)^((\"?)(.*?)\2\s*(<.*?>)?\s*[;,]\s*)?$%-
%REGEXPBLINDMATCH=$%COMMENT$%-
%-
%REM=$         Insert Name         $%-
%SUBPATT=$3$ %-
%REM=$       Insert  Address       $%-
%SUBPATT=$4$
%-
%COMMENT=_%-
%-%-%SETPATTREGEXP=$(?i)^((\"?)(.*?)\2\s*(<.*?>)?\s*[;,]\s*)?(.*)$%-
%-%-%REGEXPBLINDMATCH=$%COMMENT$%-
%-%-%SUBPATT=$5$_%-
%-
%QINCLUDE="recipient2"'%-
=====[ End  recipient2]=====

Here is a driver template.  This is the one you'd %QInclude into your main
template.  Note this example will list all recipients of the current message.
=====[QT recipient]=====
%COMMENT="%-
%-%-%IF:'%TOLIST'<>'':'%TOLIST, ':''%-
%-%-%IF:'%CCLIST'<>'':'%CCLIST, ':''%-
%-%-%IF:'%BCCLIST'<>'':'%BCCLIST, ':''%-
"%-
%QINCLUDE="recipient2"%-
%COMMENT=""%-
=====[End]=====




-=-=-=-= All New Recipient List for v2 -=-=-=-=-

The recipient list reformatting template is a general purpose template that
can be used on it's own, or in conjunction with other templates. This template
will convert a comma/semicolon separated list into a list with each entry on
it's own line.

To convert a list from the clipboard, simply copy your text to the clipboard,
type "Recipient_List" (no quotes) followed by <ctrl><space> in the editor.

When called from a template, the calling template should put the text to be
reformatted in %_RL_Text before the wrap template is called. There is also
an optional indent space parameter, %_RL_Num_Space if a certain indent is
desired.  The following two templates are: a sample print template and its
driver template.

=====[Begin example print QT]=====
-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    From: %FromName <%FromAddr>
    Date: %ODateEn %OTimeLongEn                          %IF:'%TOLIST'<>'':'
      To: %_RL_Text="%TOLIST; "%QINCLUDE="recipient driver"' %IF:'%CCLIST'<>'':'
      Cc: %_RL_Text="%CCLIST; "%QINCLUDE="recipient driver"' %IF:'%BCCLIST'<>'':'
     Bcc: %_RL_Text="%BCCLIST; "%QINCLUDE="recipient driver"'
 Subject: %FullSubj
-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

%text

-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=====[ End  example print QT]=====

=====[Begin Recipient Driver QT]=====
%_RL_Num_Space("10")%-
%SetPattRegexp="^(?s)\s{%_RL_Num_Space}(.*)\Z"%-
%RegExpMatch="%-
%___%QInclude='Recipient List'"%-
=====[ End  Recipient Driver QT]=====


=====[Begin Recipient_List QT]=====
%REM='
       Recipient List reformatting routine using features from TB v2
       Written July 2003 by Januk Aggarwal

       Notes:
          1. This template can be used alone to reformat clipboard
             contents or can be used as a reformatting engine by
             assigning text to the variable, %_RL_Text, in the driver
             template.
          2. Indenting can be specified  by defining number of leading
             spaces in %_RL_Num_Space variable.
'%-
%-
%IF:'%_RL_FirstTime'='':'%-
%___%IF:"%_RL_Text"="":"%_RL_Text(""%Clipboard; "")"%-
%___%IF:"%_RL_Num_Space"!="":"%-
%______%SetPattRegexp=""(\s{%_RL_Num_Space})""%-
%______%RegExpBlindMatch=""                                                                                                ""%-
%______%_RL_Leading_Space(%SubPatt(1))":"%-
%______%_RL_Leading_Space()"%-
%___%_RL_FirstTime="No"'%-
%-
%IF:'%_RL_Text'!='':'%-
%-
%___%SetPattRegexp=!(?x)
      ^\s*                     # Strip Leading Spaces
      (                        # SubPatt 1 - First Item + Delimiter
        (                      # SubPatt 2 - First Item
          (\"?)                # Opening Quotation marks
            (.*?)              # SubPatt 4 - Name
          \3                   # Closing Quotation marks if opening ones exist
          \s*
          (\<.*?\>)?           # SubPatt 5 - Address
        )                      # Close First Item
        \s*[;,]\s*             # Delimiter and white space
      )                        # Close First Item + Delimiter
      (.*)                     # SubPatt 6 - Remainder of list
      \Z!%-
%___%RegexpBlindMatch(%_RL_Text)%-
%-
%___%_RL_Name_Addr(%SubPatt(2))%-
%___%_RL_Name(%SubPatt(4))%-
%___%_RL_Addr(%SubPatt(5))%-
%___%_RL_Text(%SubPatt(6))%-
%-
%___%_RL_Leading_Space%-
%___%If:%_RL_Name!="":"%_RL_Name "%-
%___%_RL_Addr
%-
%QInclude("Recipient_List")'%-
=====[ End  Recipient_List QT]=====


Sender Date
[ Data extraction]
Change original sender date format to dd/mm/yyyy Added to the Library by Allie C Martin

This template will return a formatted date, based on the message's date of
creation. Because it uses the %COMMENT macro, it has a TB V2 variant
(listed below). It will take the Date: field from the message header and
return a string containing dd/mm/yyyy. You can use the returned date to
include it in the new message text or to further analyse it with %IF macros
or the like.

--------------------- Begin template --------------
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{1,2})\s"%-
%REGEXPMATCH="%HEADERS"/%-
%-
%REM="Do Month translation"%-
%Comment="%-
%SETPATTREGEXP='(?im-s)^Date\:.*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'%-
%REGEXPMATCH='%Headers'"%-
%-
%IF:"%Comment"="Jan":"01":""%-
%IF:"%Comment"="Feb":"02":""%-
%IF:"%Comment"="Mar":"03":""%-
%IF:"%Comment"="Apr":"04":""%-
%IF:"%Comment"="May":"05":""%-
%IF:"%Comment"="Jun":"06":""%-
%IF:"%Comment"="Jul":"07":""%-
%IF:"%Comment"="Aug":"08":""%-
%IF:"%Comment"="Sep":"09":""%-
%IF:"%Comment"="Oct":"10":""%-
%IF:"%Comment"="Nov":"11":""%-
%IF:"%Comment"="Dec":"12":""/%-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{4})"%-
%REGEXPMATCH="%Headers"%-
%-
%COMMENT=""%-
---------------------  End template  --------------


**** Version 2 adaptation:

--------------------- Begin template --------------
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{1,2})\s"%-
%REGEXPMATCH="%HEADERS"/%-
%-
%REM="Do Month translation"%-
%_dat="%-
%SETPATTREGEXP='(?im-s)^Date\:.*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'%-
%REGEXPMATCH='%Headers'"%-
%-
%IF:"%_dat"="Jan":"01":""%-
%IF:"%_dat"="Feb":"02":""%-
%IF:"%_dat"="Mar":"03":""%-
%IF:"%_dat"="Apr":"04":""%-
%IF:"%_dat"="May":"05":""%-
%IF:"%_dat"="Jun":"06":""%-
%IF:"%_dat"="Jul":"07":""%-
%IF:"%_dat"="Aug":"08":""%-
%IF:"%_dat"="Sep":"09":""%-
%IF:"%_dat"="Oct":"10":""%-
%IF:"%_dat"="Nov":"11":""%-
%IF:"%_dat"="Dec":"12":""/%-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{4})"%-
%REGEXPMATCH="%Headers"%-
---------------------  End template  --------------


X-Mailer Extractor
[ Data extraction]
Extracting X-Mailer headers from Headers Added to the Library by Allie C Martin

This is a template macro used to extract the X-Mailer header.

It works best as a quick template (call it XM) that you can then use
elsewhere with the %QINCLUDE='XM' command so that you can make more complex
decisions based on it.

--------------------- Begin template --------------
%SETPATTREGEXP="(?im-s)^(X-Mailer|User-Agent):\s*(.*)$"%-
%REGEXPBLINDMATCH="%Headers"%-
%Subpatt="2"
---------------------  End template  --------------

When you run this template, it returns values such as:

The Bat! (v1.61) Personal
Microsoft Outlook Express 6.00.2600.0000
Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
eGroups-EW/0.82
Forte Agent 1.8/32.553

Copyright © 1996 - 2004 Marck D. Pearlstone


Last Updated 15th-October-2009