Get variable declare in a text file

Microsoft Windows xp professional w/serv...
October 29, 2010 at 16:51:20
Specs: Windows XP
Using a batch file I am trying to get list of specific variables already define in a text file, I want to skip lines containing the colon (:) and read the variable after the Set slabel_M11_EN-UK=
ie only varaible containg "M11_EN-UK"

Am Using the the following commnad
for /F "eol=: tokens=2" %%i in (%sSOURCE%\Filename-M1_Config.txt
) do set %%i

The text file will contain strings as follows

:RemFilename: M11_Config.txt
:Rem Date: 11-10-2010
:Rem Revision:
SET slabel_M11_EN-UK=WWZX105P036_Rev00
SET sKIT_M11_EN-UK=1AAPX05K036_Rev00
SET SFilename_M11_EN-UK=AA_Rev00_%SModel%-%sLANG%.ISO
SET sFileOrder_M11_EN-UK=M11-UK.txt

SET slabel_M11_FR-FR=AAP036_Rev00
SET sKIT_M11_FR-FR=1BB5K036_Rev00
SET SFilename_M11_FR-FR=CC105036_Rev00_%SModel%-%sLANG%.ISO
SET sFileOrder_M11_FR-FR=M11-Fr.txt


The batch file is run once and for each run wants to get a specific variable ending with the word EN-UK for example

Any solution will be appreciable even if I have to structure the contents for the text file


See More: Get variable declare in a text file

Report •

October 29, 2010 at 17:56:39
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('find /v ":" ^< setsfile ^| find "EN-UK"') do (

Life is too important to be taken seriously.


Report •

October 30, 2010 at 03:16:41
Thanks a lot, a quick ask to my problem. Just tested it and it works like a treat.

I like your mottor, "live is too important to be taken seriously", I know what uou are saying at my age at 50 being diagnoseed diabetic I have to live with it for the rest of my short life in this world.

I was thinking about the solution even in bed thing I have to use 2 loops to solve it (lol)

Thansk again, you are wonderful, First time I have posted a query on the net (forum) and the result is amazing since I started using PC in 1983

Thanks, Thanks and Thanks again

Report •

October 30, 2010 at 04:19:44
LOL I wish I was 50 again.

You can make it more flexible by prompting for region.


@echo off & setLocal EnableDELAYedeXpansion

set /p R=region ?

for /f "tokens=* delims= " %%a in ('find /v ":" ^< setsfile ^| find "%R%"') do (
set s

Life is too important to be taken seriously.


Report •

Related Solutions

October 31, 2010 at 14:25:24
Thanks at lot, I will use it. I already pass the region to main batch file from command prompt as batchfilename <Module> <Language>

So what is the "Set s" doing, is it setting all the variables found in the text file?

along the same subject if I use a Set variable in a loop, it does not work except using if and goto

I will like to nest the if statements or it is not possible in a batch file as below
ie only change cab file name if language is en-us or en-uk

Thanks in advance for your help once again

@echo off

rem Set sWinpeLANG=en-uk
rem Set sWinpeLANG=en-us
rem Set sWinpeLANG=fr-fr
Set sWinpeLANG=de-de


IF "%sWinpeLANG%"=="en-us" GOTO Test1
IF "%sWinpeLANG%"=="en-uk" GOTO Test2

GOTO end

GOTO end

GOTO end


ECho LpCabFile = %LpCabFile%
ECho sWinpeLANG = %sWinpeLANG%


Report •

November 13, 2010 at 09:47:02
still struggling to get my variable to work as I expect after after making the text file a bit more readable and easy to follow

SET EN-UK slabel=WWZX105P036_Rev00
SET EN-UK sKit=1AAPX05K036_Rev00
SET EN-UK SFilename=AA_Rev00_%SModel%-%sLANG%.ISO
SET EN-UK sFileOrder=M11-UK.txt

using the batch file as
set R=EN-UK
for /f "tokens=* delims= " %%a in ('find /v ":" ^< c:\mytest.txt ^| find "%R%"') do (
set s

I want to do echo %sFileOrder% after the set s to see M11-UK.txt
I thought I replied earlier my the posting is gone somewhere as am a newbie to this site (lol)
Thanks again

Report •

Ask Question