Processing reserved charectors in a batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Posts: 3
Joined: 02 Dec 2009 08:52

Processing reserved charectors in a batch

#1 Post by SteveT44 » 11 Jan 2010 13:14


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?


Steve T.

Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 11 Jan 2010 16:40

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.

Posts: 40
Joined: 25 Jan 2008 14:05

#3 Post by jaffamuffin » 12 Jan 2010 13:59

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.

Post Reply