Need help with batch file FOR loop!!!

April 1, 2010 at 04:27:30
Specs: Windows Server 2003
Hi All,

I am new in Batch file scripting,I am stuck in for running batch file with for loop,

I have one Date.txt with
Start_Date End_Date Group_Name
01/01/2010 03/31/2010 Group1
01/01/2010 06/30/2010 Group2
04/01/2010 06/30/2010 Group3
01/31/2010 02/28/2010 Group4
... ... ...

I want to retrive those column values as parameter values in batch file.

I want output as ,

Iteration1:
Val1 = start_date1
Val2 = End_date1
Group = Group1
Run Java command with val1,val2,group1


Iteration:2
Val1 = Start_date2
Val2 = End_date2
Group = Group2
Run Java command with val1,val2,group2


Iteration3:
Val1 = Start_date3
Val2= Start_date3
Group=Group3
Run Java command with val1,val2,group3


Please help me to get solution for this problem.

Thank you experties for any help in advance.


See More: Need help with batch file FOR loop!!!

Report •


#1
April 1, 2010 at 04:31:56
Please don't double post, it's just more work for the admins.

<untested>

for /f "usebackq tokens=1-3" %%a in ("Date.txt") do (
    javacommand %%a %%b %%c
)


Report •

#2
April 1, 2010 at 04:37:37
I posted a response which might help you in your initial post, check it out it might set you on the right path

Report •

#3
April 1, 2010 at 15:35:19
Hello Judago,

Sorry For 2 posting confusion.

Thank you very much for your help.It worked perfectly fine for me.

I have one more question,how clould we get parameter value from multiple files like

Date.txt
Start_date End_date

Group.txt
Group1
Group2
Group3

Javacommand with start_date,end_date,group1 for each iteration.

Thank You once again.


Hello d4rkcell,

I think they removed other link already so I cld'nt c your response.I already solved previous one,Please help me with recent problem.

Thank you for instant response.


Report •

Related Solutions

#4
April 1, 2010 at 17:36:59
Javacommand with start_date,end_date,group1 for each iteration.

It depends, are you trying to go line-for-line so the output is the same as it would have been with the original or run every group with every date?

-


What I mean is if you have these files:

-----> Date.txt

01/01/2010 03/31/2010
01/01/2010 06/30/2010
04/01/2010 06/30/2010
01/31/2010 02/28/2010

----->Group.txt

Group1
Group2
Group3
Group4

Would it look like this:

javacommand 01/01/2010 03/31/2010 Group1
javacommand 01/01/2010 06/30/2010 Group2
javacommand 04/01/2010 06/30/2010 Group3
javacommand 01/31/2010 02/28/2010 Group4

or this:

javacommand 01/01/2010 03/31/2010 Group1
javacommand 01/01/2010 03/31/2010 Group2
javacommand 01/01/2010 03/31/2010 Group3
javacommand 01/01/2010 03/31/2010 Group4
javacommand 01/01/2010 06/30/2010 Group1
javacommand 01/01/2010 06/30/2010 Group2
javacommand 01/01/2010 06/30/2010 Group3
javacommand 01/01/2010 06/30/2010 Group4
javacommand 04/01/2010 06/30/2010 Group1
javacommand 04/01/2010 06/30/2010 Group2
javacommand 04/01/2010 06/30/2010 Group3
javacommand 04/01/2010 06/30/2010 Group4
javacommand 01/31/2010 02/28/2010 Group1
javacommand 01/31/2010 02/28/2010 Group2
javacommand 01/31/2010 02/28/2010 Group3
javacommand 01/31/2010 02/28/2010 Group4


Report •


Ask Question