Batch File

October 30, 2009 at 13:50:11
Specs: Windows XP
Hello:

I have been following the examples in here and they are great. I am stuck with one batch file though and am wondering if you could help me.

I need a batch file that adds two lines to a file with an .inp extension. There are 1000 different .inp files and the two lines for each are different. I have written the script for the first 5 but would rather automate the remaining 995 as opposed to cut and past and replace.

Here is what I have:

echo DATA: FILE IS REP1.DAT; >>FS_1.INP
echo SAVEDATA: FILE IS REPFS1.DAT; SAVE = FSCORES; >>FS_1.INP

NOTE: This is the two lines for the first file.

echo DATA: FILE IS REP2.dat; >>FS_2.inp
echo SAVEDATA: FILE IS REP2FS.dat; SAVE = FSCORES; >>FS_2.inp

NOTE: This is the two lines for the second file.

I need it to go all the way to:

echo DATA: FILE IS REP1000.DAT; >>FS_1000.inp
echo SAVEDATA: FILE IS REP1000FS.dat; SAVE = FSCORES; >>FS_1000.inp

Each of the two lines has a number that increases by 1 for each file. So

REP1000.DAT goes from REP1.dat to REP1000.dat

FS_1000.inp goes from FS_1.inp to FS_1000.inp

REP1000FS.dat goes from REP1.dat to REP1000.dat


Any thoughts? Thanks.


See More: Batch File

Report •


#1
October 30, 2009 at 16:40:49
For /L %%A in (6,1,995) do (
  echo DATA: FILE IS REP%%A.DAT; >>FS_%%A.INP
  echo SAVEDATA: FILE IS REPFS%%A.DAT; SAVE = FSCORES; >>FS_%%A.INP
)


Report •

#2
October 30, 2009 at 18:27:38
Works great.

I am also trying to write a batch fall to call the program
(mplus) to run the 1000 files that I just created. Is there a way
to do:

CALL Mplus FS1.inp to Call Mplus FS1.inp without writing the
Call Mplus FS#.inp 1000's times? Thanks again.


or /L %%A in (6,1,995) do (
echo DATA: FILE IS REP%%A.DAT; >>FS_%%A.INP


Report •

#3
October 30, 2009 at 18:28:12
Whoops...ignore the bottom of that message stating:

or /L %%A in (6,1,995) do (
echo DATA: FILE IS REP%%A.DAT; >>FS_%%A.INP


Report •

Related Solutions

#4
November 2, 2009 at 06:41:17
You should really post this in the programming forum. By the way here is the code you are looking for....

For /L %%A in (1,1,1000) do (CALL Mplus FS%%A.inp)

http://command-line-programming.sui...


Report •


Ask Question