Reading Value from Batch File

February 3, 2010 at 20:16:14
Specs: Windows XP
Hi Folks,

I have in my 'compile_schema.txt' following data
LS001/m_m_001_01/m_001_01_01_co.fla
LS001/m_m_001_01/m_001_01_02_co.fla
LS001/m_m_001_01/m_001_01_03_co.fla

line by line i want to break this data line wise & print like as follow in DOS when i will run batch file

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_02.xml
BUILDFILE LS001/build_m_m_001_03.xml

Can any one help me out below is what i tried till ..

setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (compile_schema.txt) do (
set /a N+=1
set v!N!=<compile_schema.txt
rem Set storea=v!N!
echo v!N!
)

set MODULEPREFIX=%Choice:~0,4%
echo Choice : %MODULEPREFIX%

last two lines are not usable till i store data it's like i am trying to do substr .once i store value

during print here is what i getting now

ECHO is off.
ECHO is off.
ECHO is off.

your help is highly appreciated please..


See More: Reading Value from Batch File

Report •


#1
February 3, 2010 at 20:33:49
maybe try to let the 'delims' & 'tokens' do some of the work:
(foll. is all on one line! i'm never sure when this forum thingey is gonna bust up my lines wrong)

for /f %%a "tokens=1,2 delims=/" %%a in (schema.txt) do >> newfile echo BUILDFILE %%a/build_%%b.xml


Report •

#2
February 3, 2010 at 20:50:28
Hi nbrane,

Thanks for your wonderful help , here is wat i want & still what with i strugling

for /f "tokens=1,2 delims=/" %%a in (compile_schema.txt) do ( echo BUILDFILE %%a/build_%%b.xml )

this gives

following when i run file batch file :

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_01.xml

But iwant it should give Outfut

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_02.xml
BUILDFILE LS001/build_m_m_001_03.xml

looking for reply...

Regards,
Ganesh


Report •

#3
February 3, 2010 at 21:15:10
for /f "tokens=1,2 delims=/" %%a in (compile_schema.txt) do (
set /a N+=1
echo %%b!N!
echo BUILDFILE %%a/build_%%b.xml
)


set MODULEPREFIX=%Choice:~0,4%
echo Choice : %MODULEPREFIX%
rem IF NOT %MODULEPREFIX% == m_m_ GOTO REPEAT

set LEARNSEQUENCEFOLDER=LS%Choice:~4,3%
echo LEARNSEQUENCEFOLDER : %LEARNSEQUENCEFOLDER%
SET ONLYMODULE=%Choice%

SET MODULE=build_%Choice%.xml
echo MODULE=build_%Choice%.xml
echo compiling files in %LEARNSEQUENCEFOLDER%/%MODULE%

IF NOT EXIST %LEARNSEQUENCEFOLDER%/%MODULE% GOTO REPEAT

echo.
echo Creating Build for files in Module %MODULE% to the Server
echo.
echo.

Guess doing wrong!!


Report •

Related Solutions

#4
February 3, 2010 at 22:13:24
ah! got me! missed the incremental...
(i knew there was more to this'un)
for /f "tokens=1-9 delims=/_" %%a in (schema) do (
>> newfile echo BUILDFILE %%a/build_%%b_%%c_%%d_%%i.xml

(i might have indexes mixed up a tad, but i'm sure you get the idear about tokens assigned to var.s if not see: for /?
or set /?)
it could also be written hardwired (based on positions) but
i always try to avoid that, for some reason.
keep posted, esp it not working...


Report •

#5
February 3, 2010 at 22:53:03
Woderful man :)

Working now as per i want.

Actully i am completely new in this field just joint & this is 2nd day in this coding but learning lot.

I was not aware about tokens & delims hence reading this,
http://ss64.com/nt/for_cmd.html

also if you had any beginee web refrences please let me know.

Thank you so much nbrane for your kind help.

Regards,
Ganesh


Report •

#6
February 3, 2010 at 23:08:22
good! :)
standbys for learning (at cmdprompt): set /? for /? if /? (etc)
msdn, bless'em, has tons, as i'm sure you know.
you got good handle on it already. good luck

Report •

#7
February 3, 2010 at 23:08:22
How can i store this value,

%%a/build_%%b_%%c_%%d_%%i in some variable ..

like as i want to store inside,

Set temp = _%%b_%%c_%%d_%%i

echo %temp%

i tried this not working !!


Report •

#8
February 3, 2010 at 23:12:39
hey this works

SET temp=_%%b_%%c_%%d_%%i
echo %!temp!

Cool :)


Report •

#9
February 3, 2010 at 23:47:13
echo %!temp!
ok!
the leading percent not needed, (it's unbalanced anyhows).
other than that, good job!
most of this, (doing things as i do) is just hacking until i get result, but sometimes you really need an example.
hacking it out the hard way makes me more likely to remember, so i often beat myself silly working on something.

Report •

#10
February 4, 2010 at 02:29:30
Hello nbrain

Sorry to disturb you again.. Do you know any command for printing all content of DOS Screen into some text file.

Like as suppose .. my DOS Screen contain following text,


.................. Creating Build for Multiple Modules listed in compile_schema.txt ..................

................. Build started for: LS001/build_m_m_001_01 .................


Buildfile: LS001\build_m_m_001_01.xml
[echo] FLEX_HOME -> :E:\Bertelsmann\newVSS\05 WIP\SCOYO\build\LS001: (remember to call ant -DFLEX_HOME=...)

clean:

validateManifests:
[xmlvalidate] 1 file(s) have been successfully validated.

deployAssets:
[echo] Please make sure to copy all needed assets to the output folder (bin)!
[mkdir] Created dir: E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01\assets
[copy] Copying 173 files to E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01\assets
[copy] Copied 5 empty directories to 1 empty directory under E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_
[copy] Copying 1 file to E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01

buildModules:
[mxmlc] Loading configuration file E:\Bertelsmann\newVSS\05 WIP\SCOYO\build\module-config.xml
[mxmlc] Initial setup: 31ms
[mxmlc] Loaded 13 SWCs: 1078ms
[mxmlc] Files: 484 Time: 6938ms
[mxmlc] Linking... 234ms
[mxmlc] Optimizing... 203ms
[mxmlc] SWF Encoding... 235ms
[mxmlc] E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01\m_m_001_01_01_co.swf (1169236 bytes)
[mxmlc] Total time: 8734ms
[mxmlc] Peak memory usage: 72 MB (Heap: 42, Non-Heap: 30)
[mxmlc] Loading configuration file E:\Bertelsmann\newVSS\05 WIP\SCOYO\build\module-config.xml
[mxmlc] Initial setup: 187ms
[mxmlc] Loaded 13 SWCs: 657ms
[mxmlc] Files: 485 Time: 5531ms

it should print this complete text at last into some new text file.

Regards,
Ganesh


Report •

Ask Question