tags:

views:

18

answers:

1

I have a file that contains some information about the product I work on. The information I'm specifically interested in is the version of the product.

I need to read in this version and store it in a variable that I can manipulate so I can increment the version number appropriately. I'm trying to use a line like this:

for /f "tokens=2" %%i in ('type product.properties^|find "about.version=Version"') do set currentversion=%%i

I know that the file contains the string "about.version=Version" and it is immediately followed by a space and then the Version number. However when I try and echo %currentversion% there is nothing stored in it.

I'm on Windows XP, thanks.

+2  A: 

On note: You don't need type, just give find the file name.

If you are doing above thing in a for loop, if statement or any other kind of parenthesized block in the batch file, then enable delayed expansion with

setlocal enabledelayedexpasion

earlier in the batch file first and use !currentversion! instead of %currentversion%.

Joey
@Johannes Rössel: So I tried removing the type call, played with it as much as I can but I can't get it to actually make the find call and search that. It just searches the 'find "about.version=Version" product.properties' and stores "about.version into %currentversion%
Nedloh
Nevermind I just played with it more and got it to work using a way I swear I had tried already. Thanks.
Nedloh