Find version inside a file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Shawn@Rogers
Posts: 7
Joined: 13 Feb 2012 15:53

Find version inside a file

#1 Post by Shawn@Rogers » 14 Feb 2012 11:53

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

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

Re: Find version inside a file

#2 Post by Squashman » 14 Feb 2012 12:17

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

Shawn@Rogers
Posts: 7
Joined: 13 Feb 2012 15:53

Re: Find version inside a file

#3 Post by Shawn@Rogers » 14 Feb 2012 15:03

Thank you,

I also tried

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

And it worked.

Post Reply