Click here for important information about

delete specific words in htm

January 6, 2011 at 20:08:04
Specs: Windows XP
Hi guys,
I'm trying to create a batch file that removes certain text from htm files.
I want to remove certain html tags (like red highlights) and delete strike-through text (which is between < s > and < /s > tags).
I have several folders containing these html files. Just want to drag and drop the multiple files on the .bat The batch file should replace the original file with the modified one.

type 1.htm | find /v "< s >" | find /v "< /s >" > 2.htm

didn't work for me. It deletes the complete line in 2.htm and not just the text within < s > and < /s >

F1 please

See More: delete specific words in htm

January 6, 2011 at 20:12:18
< and > are redirection characters, you need to escape them with a caret (^< s ^>).

Can I put a question here?

Report •

January 7, 2011 at 00:35:37
@Matt123, that's not what the problem is, the < and > are ok because they are enclosed in quotes and so they don't get treated as redirection characters.

The problem is you are trying to delete a substring from within a line. Batch is not very good at doing that. You may find it easier to write it in VBScript, or use a helper utility such as sed (available from GnuWin32).

Also, you are assuming all your text within the < s > and < /s > is on the same line. Is that a valid assumption? In html, it is allowed to span any number of lines.

Report •

January 7, 2011 at 01:16:18
FIND did what you told it to. It is a line based util. So is FINDSTR.

Batch is not well suited to rpocessing html. Even on it's best behavior it will probably mangle the indenting.

Life is too important to be taken seriously.


Report •

Related Solutions

January 7, 2011 at 14:18:16
Thanks for the tip klint.

Can I put a question here?

Report •

January 8, 2011 at 22:08:46
Thanks for your responses.
Klint, I'll try VBScript. It's a good suggestion.
And yes, my text in < s > and < /s > spans several line.
I'll try VBScrips on Monday and will let you guys know.

Report •

Ask Question