Find result truncated after first closing bracket

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Zoggy
Posts: 1
Joined: 12 Nov 2013 11:58

Find result truncated after first closing bracket

#1 Post by Zoggy » 12 Nov 2013 12:40

Hi, please help :cry:

I'm trying to read a .js file which contains version information at the end of a particular line. The extract below from a batch script should find the line containing the version information and store it in a variable called Version which I should be able to extract the version from.

The problem is that the string that gets passed to %%a is truncated at the first closing bracket it finds which is before the version information I need. I'm pretty sure the script is interpreting the bracket as an end of string or end of command character even though I've set delims to be just semicolons. %%b would return me the next bit and so on but the .JS script changes frequently and the verison info may be in a different position each time.

Has anyone got any suggestions on how to stop this from happening as it is winding me up! It would be nice if I could tell "Find" to ditch everything before the found search string but I guess it can only return the entire line....bring back grep!!! :(

for /F "tokens=1* delims=;" %%a in ('findstr /I /C:"xyz\.versions={" "!ProductPath!\!Product!.js"') do (
if not ERRORLEVEL 1 (
set Version=%%a
echo.%%a
rem some truncation logic on "Version" to extract the actual version string
)
)

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Find result truncated after first closing bracket

#2 Post by Squashman » 12 Nov 2013 13:24

Can we see an example of the input file.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Find result truncated after first closing bracket

#3 Post by foxidrive » 12 Nov 2013 16:15

Yes, we need to see the line you are trying to extract. A parenthesis will not affect it in the way you describe, something else is happening.

Post Reply