can i use compound command in "for" command?

  • Thread starter Thread starter thinktwice
  • Start date Start date
T

thinktwice

for /F "tokens=1,2,3* delims=," %%i in (myfile.txt) do ( command1,
command2...)
could i?
 
thinktwice said:
for /F "tokens=1,2,3* delims=," %%i in (myfile.txt) do ( command1,
command2...)
could i?

You probably could but you need to spend a little more of your
time in explaining precisely what you're trying to achieve.
 
thanks for you quick relay :)

here is what i want to do.
//myfile.txt
"project1"=vc2005 //projectname=projecttype
"project2"=vc6
"project3"=csharp

i want to write a batch file to read this file and automatically build
these projects.
for /F "tokens=1,2,3* delims==" %%i in (myfile.txt) do (set
projectname=%%i set projecttype =%%j)
but seems i can't write in the above style. can you tell me how to
write compound command in for loop?

Pegasus (MVP) $B<LF;!'(B
 
Here is one way of doing it:
1. @echo off
2. setlocal enabledelayedexpansion
3. set Source=d:\temp\test.txt
4.
5. for /F "tokens=2,4 delims==" %%a in ('type "%Source%"') do (
6. set projectname=%%a & set projecttype=%%b
7. echo Project name=!projectname! Project type=!projecttype!
8. )
 
Besides the parenthesis someone else posted, you can also call one batch
file from another even passing parameters to it as required.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top