Simple Batch File

August 24, 2009 at 01:30:43
Specs: Windows XP
I'm new to the batch file world and am in
desperate help for something I'm sure is very

I need to copy a .txt file into the folder that
contains my DOS program (called wavgen)
and rename it accelerogram.dat so that
wavgen can read it. The program has to be
started, and an input of 0.05 has to be
entered. Then the output file compatible.dat
needs to be copied as/ saved as a different
name. I'll be repeating this code, so if I need 5
runs of the program, there will be five repeats
of this, and the xcopy should basically dump
input into the accelerogram.dat file and save
the output from the compatible.dat file into a
separate file with a new name.

ERASE accelerogram.dat
XCOPY A1.dat to accelerogram.dat (?
confused how to code this)
START wavgen
Somehow prompt an input of 0.05
XCOPY compatible.dat to C1.dat (? again

Any help with any portion of this would be
greatly appreciated. Thanks!!


See More: Simple Batch File

Report •

August 24, 2009 at 21:09:36
So you want to delete the existing accelerogram.dat file
rename A1.dat to accelerogram.dat
START wavgen
echo .05
rename compatible.dat to C1.dat?
and then do that 5 times in a row

So that sound like the basic flow of how you want this thing to work?

Report •

August 24, 2009 at 22:47:44
My main issue is getting the program to read 0.05 ...
everything else is working now. So when the program starts,
it automatically reads the .dat files required, and then asks
for a damping ratio. So I have to type 0.05 and then press
enter for the program to continue. I've tried just placing the
value 0.05 after "start wavgen" on the same line, on the next
line, etc.


Thanks for your help!!

Report •

August 25, 2009 at 07:53:14
Try this:

echo 0.05|wavgen

The pipe character (|) runs the command to the left of it and makes its output the input of the command to the right of it. It may or may not work, depending on how wavgen gets its input.

Report •

Related Solutions

August 25, 2009 at 17:19:08
I like Klint's solution if it works, the problem is not knowing anything about this wavgen app it's hard to tell you a solution. What I'm thinking is, instead of calling wavgen from the batch, have it call a .vbs that opens wavgen then sends the keys you want. Save the following, editing how you need and add
call wscript "the .vbs file" to your batch

set wshshell = createobject("") "cmd /k wavgen"
wscript.sleep 1000
WshShell.SendKeys "."&"0"&"5"
WshShell.SendKeys "{ENTER}"
WshShell.Sendkeys "%{f4}"

Report •

August 25, 2009 at 17:24:46
WshShell.SendKeys "."&"0"&"5"
Don't do this. ".05" is much easier to read, and executes faster. "cmd /k wavgen"
Don't use .Run(), use .Exec(). Exec() gives you access to the job's StdIn.

Report •

Ask Question