Computing.Net > Forums > Programming > Batch script string parsing

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch script string parsing

Reply to Message Icon

Name: WebMonk
Date: March 31, 2009 at 12:45:12 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

I've got a batch script that runs through a file, but every time it hits a line with a less-than sign, it bombs. Here's the script:

REM Gets line from earlier
SET Line=%*
REM Remove quotes from the line
SET Line=%Line:"=%
REM Tests the line. This is in a loop.
IF "%Line:~0,6%"=="[HKEY_" FOR /F "tokens=5 delims=\]" %%A IN ('ECHO.%Line%') DO ECHO %Line%

It can parse through a file that contains stuff from a registry file, but when it runs across a line with a less-than sign, it complains, saying "less-than was unexpected at this time."

How can I get around that? How can I strip out the less-than signs like I can strip out the quotes?



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: March 31, 2009 at 18:56:40 Pacific
Reply:

how does the file that you are going to parse look like? and what is your final output look like?


0

Response Number 2
Name: WebMonk
Date: April 1, 2009 at 08:55:53 Pacific
Reply:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Software\etcetc]

[HKEY_LOCAL_MACHINE\Software\blahblah]
"Coors"="C:\\Coordinates"

[HKEY_LOCAL_MACHINE\Software\Yadayada]
"CodeDir"="C:\\Code"
"LocDir"="C:\\Locators"

[HKEY_LOCAL_MACHINE\Software\yeahyeah]
"Models"="<models><model name= yadda yadda yadda Label=\"Model Dataset\" dataset-type=\"DVA\" optional=\"true\"/></model></models>

"


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch script string parsing

Batch Scripts - string parsing www.computing.net/answers/programming/batch-scripts-string-parsing/12733.html

batch file string parsing www.computing.net/answers/programming/batch-file-string-parsing/16603.html

Batch Scripting-String Extraction www.computing.net/answers/programming/batch-scriptingstring-extraction/14471.html