1.

Solve : Batch Help - delete unneccessary quoted messages in email conversation?

Answer»

Hi everyone,

I've never dealt with batch files before, but I know some Delphi and Java.

My problem is that I have a really long email conversation that I want to print off. I extracted everything into a big HTML file. I could print it off now, but each conversation includes several quotations of messages sent before. You know that each time an email has been answered the conversation so far was quoted underneath the new message. Now I see in the HTML code that the quotations are between two tags. It begins with


Could someone be so NICE and give me the code for the batch file? Or at least tell me what commands I would need? Thanks so much in advance!

Buff

PS: if no one knows how to do this maybe someone know a place to get help...a.txt
Code: [Select]1text text text text text text text text text text text text text
1text text text
1text text
1text text text text text text text text
1text text
<BLOCKQUOTE
text text text text text
text text
text text
text text text text text
text text text
</BLOCKQUOTE
2text text text text text
2text text text
2text text
2text text text text text text
<BLOCKQUOTE
text text text text text
text text
text text
text text text text text
text text text
</BLOCKQUOTE
3text text text text text
3text text text
3text text
3text text text text text text

batch:
Code: [Select]echo off
setlocal enabledelayedexpansion
set skip=0

for /f "tokens=*" %%a in ('type a.txt') do (
if !skip! equ 1 (
if "%%a" equ "</BLOCKQUOTE" set skip=0
) ELSE (
if not "%%a" equ "<BLOCKQUOTE" (echo %%a) ELSE (set skip=1)
)
)
)
pause
output:
Code: [Select]1text text text text text text text text text text text text text
1text text text
1text text
1text text text text text text text text
1text text
2text text text text text
2text text text
2text text
2text text text text text text
3text text text text text
3text text text
3text text
3text text text text text text
Press any key to continue . . .Hey thanks for the quick reply...

I'll try this out next week when I'll be able to use my pc again.

Have a great day! Quote from: Buff on JULY 01, 2009, 10:46:37 AM
So what I need my batch file to do is to look for every blockquote opening tag and to delete everything after that until the closing blockquote tag.
you can see here for example on how to do it with vbscript
Quote from: devcom on July 01, 2009, 04:55:51 PM
Code: [Select]echo off
setlocal enabledelayedexpansion
set skip=0

for /f "tokens=*" %%a in ('type a.txt') do (
if !skip! equ 1 (
if "%%a" equ "</BLOCKQUOTE" set skip=0
) ELSE (
if not "%%a" equ "<BLOCKQUOTE" (echo %%a) ELSE (set skip=1)
)
)
)
pause
it would be good to take care of both open and close tags on the same line as wellJust a sideways thought - you could (Im not expert enough) edit a STYLE into the html that renders blockquotes invisible, then print it off from a browser - maybe

Graham Code: [Select]<STYLE>
BLOCKQUOTE
{
display : none;

}
</STYLE>

try placing that in the section of the HTML file. Quote from: BC_Programmer on July 02, 2009, 09:56:20 AM
Code: [Select]<STYLE>
BLOCKQUOTE
{
display : none;

}
</STYLE>

try placing that in the <HEAD> section of the HTML file.
yes, that was the sort of thing I had in mind !
ThanksThanks...
so far this has worked out but now I have left some quotes that ARENT WITHIN blockquote tags but all start off with > or actually ">". So once again: how do I delete each line that starts off with ">"?

Thanks =)

Buffa.txt
Code: [Select]1text text text text text text text text text text text text text
1text text text
1text text
1text text text text text text text text
1text text
"&gt;" text text text text text
"&gt;" text text
"&gt;" text text
"&gt;" text text text text text
"&gt;" text text text
2text text text text text
2text text text
2text text
2text text text text text text

.bat
Code: [Select]echo off
setlocal enabledelayedexpansion

for /f "tokens=*" %%a in ('type a.txt') do (
echo %%a | findstr ""^&gt;"" >nul || echo %%a
)
pauseHey...

it's not working =(
Could it be that the batch file also tries to execute commands from the text file (a.txt)? I think it tries to find the command "gt" because the &-sign is in front of it in my textfile. How do I tell the batch file not to try to do this? Code: [Select]C:\>type a.txt
1text text text text text text text text text text text text text
1text text text
1text text
1text text text text text text text text
1text text
"&gt;" text text text text text
"&gt;" text text
"&gt;" text text
"&gt;" text text text text text
"&gt;" text text text
2text text text text text
2text text text
2text text
2text text text text text text

C:\>a.bat
1text text text text text text text text text text text text text
1text text text
1text text
1text text text text text text text text
1text text
2text text text text text
2text text text
2text text
2text text text text text text
Press any key to continue . . .
how ?ok...that works but i have something like this:

Code: [Select]1text text text text text text text text text text text text text
1text text text
1text text
1text text text text text text text text
1text text
&gt; text text text text text
&gt; text text
&gt; text text
&gt; text text text text text
&gt; text text text
2text text text text text
2text text text
2text text
2text text text text text text
>text text text text
>text text
>>text text text text text text
>>text text
>>text text text text text text
>>text text
3text text text text text text
3text text
3text text text text text text
3text text
3text text text text text text text text

and it seems that if i read this with Code: [Select]('type a.txt') it tries to execute a command because of the &-sign in line 6-10

any idea how to solve this?

-----
hey this works =)

Code: [Select]echo off
setlocal enabledelayedexpansion

findstr /V /B /C:"&gt;" original.html > clean.html

pause


Discussion

No Comment Found