Page 1 of 1

Find version inside a file

Posted: 14 Feb 2012 11:53
by Shawn@Rogers
Hi, the title is not the best but you will understand by seeing it:

File: R:\info.txt
content:

Code: Select all

image a
version 3.0
computer HP EliteBook 8540p
system Windows 7 x86

Behavior:
If image is a then load a.bat
If image is b then load b.bat


I found something that could work but I don't understant the example:
for /f "tokens=2 delims= " %%i in ('type N:\script\SQLicenseList.txt ^| find "%ComputerName%"') do (
volumeid c: %%i
)


Thank you for your help

Re: Find version inside a file

Posted: 14 Feb 2012 12:17
by Squashman

Code: Select all

for /f "tokens=2 delims= " %%G in ('type info.txt ^| findstr /B /C:"image"') do (
     IF "%%G"=="a" call a.bat
     IF "%%G"=="b" call b.bat
)

Or you could do it like this.

Code: Select all

for /f "tokens=2 delims= " %%G in ('type info.txt ^| findstr /B /C:"image"') do call %%G.bat

Re: Find version inside a file

Posted: 14 Feb 2012 15:03
by Shawn@Rogers
Thank you,

I also tried

do (
N:\script\%%G.bat
)

And it worked.