Page 1 of 1

Processing reserved charectors in a batch

Posted: 11 Jan 2010 13:14
by SteveT44
Hello,

I am parsing a file containing html tags. At issue is the greater than and less than symbols (<>) . A for-do loop reads these lines in fine. The problems occur when I attempt to set another variable to equal the variable containing these symbols or echoing the variable to screen or a file. The error returned is "< was unexpected at this time." I have tried enabledelayedexpansion and enclosed the variables in double quotes but I can't lick this problem short of preceding each < and > with the ^ character.

Anybody have any suggestions?

Thanks

Steve T.

Posted: 11 Jan 2010 16:40
by avery_larry
Replace the special characters with non-special characters using a for loop that has the special characters as the delimiters.


To be honest, this can be painfully difficult in "pure" dos. VBscript or other alternatives would serve you better.

Posted: 12 Jan 2010 13:59
by jaffamuffin
depending on what ou are doing, sed, grep, awk may be more suited to this. These can be called and controlled from a batch script.

Also, consider storing the data in temp text files rather than in variables.

As mentioned handling these sort of things is a pain in cmd, and often involves terribly ugly hack and workarounds.