On 3/8/2013 6:37 PM, Dennis Lee Bieber wrote:
> Well, as I recall, filters are stored in plain text...
> CRYPTIC but plain text <G> [in file filters.pce]
I will take the liberty of annotating it for you:
> 3 [file header or version, or who cares?]
> rule Subject:secretsline [each filter's first word is "rule"]
> junk [one line per filter action]
> stop
> incoming [one line per check mark: incoming? outgoing? manual?]
> header Subject: [first condition (3 lines)]
> verb contains
> value secretsline
> conjunction ignore [between the two conditions]
> header [second condition (3 lines), even if ignored]
> verb contains
> value
> rule Subject:tmg users group [next filter has begun]
> status 1 [actions]
> transfer Trash.mbx
> stop
> incoming [check marks]
> manual
> header Subject: [condition 1]
> verb contains
> value tmg users group
> conjunction ignore
> header [condition 2]
> verb contains
> value
> rule Subject:TMG User Group Meeting [next filter]
> transfer Trash.mbx
> stop
> status 1
> incoming
> manual
> header Subject:
> verb contains
> value TMG User Group Meeting
> conjunction ignore
> header
> verb contains
> value
Etc.
> Someone could probably write a script to parse these into something
> like an Excel spreadsheet (or a CSV file, for simplicity);
> Edit; then another script to export back to the .pce file.
Take note of some places where there may be a variable number of lines,
which you must account for in any such scheme, whereas applications
which only "organize" and re-order filters need only
keep each individual rule's lines together,
without altering any internal content of any rule.
I have written a brief text processing script (filters.awk)
and a brief Windows command file (filters.cmd)
for the special purpose of instantly and accurately setting the
"manual" check box of every Eudora filter per any one of these criteria:
o Set "Manual" to match "Incoming" in all filters.
o Set "Manual" to match "Outgoing" in all filters.
o Set "Manual" if either "Incoming" or "Outgoing"
o Set "Manual" if neither "Incoming" nor "Outgoing"
o Set "Manual" in all filters.
o Remove "Manual" from all filters.
The first two conditions above are obviously necessary
to guarantee that manual filtering exactly matches
either incoming filtering or outgoing filtering,
so that you may accurately test each such separate filtering
manually, without having to actually receive or send messages.
It is also probably obvious how tedious it is
to accurately change between each of the above configurations
if you have a large number of filters to deal with,
which was the motivation for my automating this process.
I suppose it would be disappointing not to have the actual command
and script files accompany all that description, so here they are, FWIW:
----- filters.awk -----
# AWK script for setting which Eudora filters to mark "manual"
# (store this script in a file named filters.awk,
# in the same directory as you find the filters.pce file)
$1 == "rule" { rule = 1 } # start of new filter rule
# Mark which filters? incoming, outgoing, neither, either, all, or none
$1 == "header" { if ( rule &&
( manual ~ /^inc/ && inc ||
manual ~ /^out/ && out ||
manual ~ /^nei/ && !(inc) && !(out) ||
manual ~ /^eit/ && ( inc || out ) ||
manual ~ /^all/ )) print "manual" ;
rule=inc=out=0 } # insert "manual" here
$1 == "incoming" { inc=1 } # current rule has "incoming" box checked
$1 == "outgoing" { out=1 } # current rule has "outgoing" box checked
$1 != "manual" # drop "manual" here, then insert it above
# END OF filters.awk
----- filters.cmd -----
@ echo off
rem This file should be named: Filters.cmd
rem This file should reside in a Eudora Data folder,
rem where Filters.pce resides.
rem Run this command only while Eudora is not running.
rem
if not exist owner.lok goto nolock
echo.
dir owner.lok | find /i "lok"
echo WARNING: EUDORA IS CURRENTLY IN USE, please close it first.
echo.
pause
goto end
: nolock
echo.
echo Making backups of Filters.pce
echo (restore Filters.pce if any further error occurs in this script)
if exist Filters.pc8 copy Filters.pc8 Filters.pc9 /y
if exist Filters.pc7 copy Filters.pc7 Filters.pc8 /y
if exist Filters.pc6 copy Filters.pc6 Filters.pc7 /y
if exist Filters.pc5 copy Filters.pc5 Filters.pc6 /y
if exist Filters.pc4 copy Filters.pc4 Filters.pc5 /y
if exist Filters.pc3 copy Filters.pc3 Filters.pc4 /y
if exist Filters.pc2 copy Filters.pc2 Filters.pc3 /y
if exist Filters.pc1 copy Filters.pc1 Filters.pc2 /y
if exist Filters.pc0 copy Filters.pc0 Filters.pc1 /y
copy Filters.pce Filters.pc0 /y
if errorlevel 1 goto skip
rem IMPORTANT: make sure you've kept a backup elsewhere,
rem IMPORTANT: not just the copies made above
echo.
echo Editing Filters.pce
echo.
rem Ask a question and save the reply (which must be a lower-case word)
rem (just press Enter with no input to skip running AWK)
set /p manual=Mark which filters? incoming, outgoing, neither, either, all, or none:
if errorlevel 1 goto skip
rem Run AWK using the script file saved earlier
awk.exe -f Filters.awk manual="%manual%" Filters.pc0 > Filters.pce
rem notepad.exe Filters.pce
: skip
echo.
pause
rem Optionally launch Eudora
rem start "" /b "path to Eudora.exe" "path to data folder"
: end
rem END OF filters.cmd
----- Additional info -----
You also need the executable program awk.exe,
which you can extract from the following "binaries" zip file:
<
http://gnuwin32.sourceforge.net/packages/gawk.htm>
<
http://gnuwin32.sourceforge.net/downlinks/gawk-bin-zip.php>
[files awk.exe, gawk.exe and gawk-3.1.6.exe are all identical]
--