Hello, Loek

> I  have  a  filter  defined  that  writes  attachments  to directory
> blablabla/%OSUBJ  if  certain  messages from certain clients contain
> attachments.  This  works,  except when %OSUBJ contains symbols that
> are not allowed in directory names, like : and '

> How  do  I  filter  these symbols? I'll need to put something around
> %OSUBJ, but what?

> Also,  I  need  to  make  sure the directory names do not become too
> long,  so  an  instruction  to truncate the directory name to say 50
> characters would be welcome.

> I  can find the needed directory names also in the mails themselves,
> but SETPATTREGEXP etc. don't seem to work either.

> Anything else I can do?

Look at this template (version for testing and understanding):

%_TOREPLACE="'te'sta':tor::"%-
%_illchars=`\<\>\:\"\/\\\|\'`%-
%SETPATTREGEXP="(?ms)^([^%_illchars]*)([%_illchars]*|\z)([^%_illchars]*)([%_illchars]*|\z)([^%_illchars]*)([%_illchars]*|\z)([^%_illchars]*)([%_illchars]*|\z)"%-
%REGEXPBLINDMATCH(%_TOREPLACE)%-
%_OUTPUT="%SUBPATT(1)%SUBPATT(3)%SUBPATT(5)%SUBPATT(7)"%-
TOREPLACE: %_TOREPLACE
OUTPUT: %_OUTPUT
%_LONGTEXT="1234567890123"%-
%_LIMIT="5"%-
%SETPATTREGEXP="(?ms)^(.{0,%_LIMIT})"%-
%REGEXPBLINDMATCH(%_LONGTEXT)%-
%_SHORTTEXT="%SUBPATT(1)"%-
LONGTEXT: %_LONGTEXT
LIMIT: %_LIMIT
SHORTTEXT: %_SHORTTEXT

First Regexp remove 4 illegal characters from %_TOREPLACE (or more, if
those characters are together). If You want to remove more, You'll need
add new  ([^%_illchars]*)([%_illchars]*|\z)  in %SETPATTREGEXP and
new %SUBPATT(9/11/13...) in %_OUTPUT. You could also use %XMP_StrRepl
from XMP plugin - this is a better version, but You must to install
this plugin

%_TOREPLACE(%OSUBJ)%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,'<',))%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,'>',))%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,':',))%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,'"',))%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,'/',))%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,'\',))%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,'|',))%-
%_TOREPLACE(%XMP_StrRepl(%_TOREPLACE,"'",))%-
Done: %_TOREPLACE%-


In the second half of template is a regexp to limit the length of
output (based on variable %_LIMIT).

Now all You must to do is to create a quick template with handle - for
example - 'spsubj' and with this content:

%_TOREPLACE="%OSUBJ"%-
%_illchars=`\<\>\:\"\/\\\|\'`%-
%SETPATTREGEXP="(?ms)^([^%_illchars]*)([%_illchars]*|\z)([^%_illchars]*)([%_illchars]*|\z)([^%_illchars]*)([%_illchars]*|\z)([^%_illchars]*)([%_illchars]*|\z)"%-
%REGEXPBLINDMATCH(%_TOREPLACE)%-
%_OUTPUT="%SUBPATT(1)%SUBPATT(3)%SUBPATT(5)%SUBPATT(7)"%-
%_LIMIT="40"%-
%SETPATTREGEXP="(?ms)^(.{0,%_LIMIT})"%-
%REGEXPBLINDMATCH(%_OUTPUT)%-
%SUBPATT(1)%-

This template will remove illegal characters from %OSUBJ (if not all
of them, then add more parenthesis to regexp, as I described above, or
use XMP) and will truncate a length of %OSUBJ to 40 characters. Now
all You must to do is to add %QINCLUDE(spsubj) to path in Extract
Attachments action in filter, from blablabla/%OSUBJ to
blablabla/%QINCLUDE(spsubj).

-- 
Pozdrowienia,
 Konrad Szkudlarczyk


________________________________________________
Current version is 5.2.2 | 'Using TBUDL' information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to