Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch File Q: Please Help Me!  (Read 46292 times)

0 Members and 1 Guest are viewing this topic.

dosnovice

  • Guest
Batch File Q: Please Help Me!
« on: July 26, 2005, 12:24:24 PM »
This will probally seem like a stupid question to any experienced dos user, but I need to know if it is possible for a batch file to answer prompts in a program.  I want to create a batch file that will start a dos program (called rmovave) and answer the prompts so the program will run without me having to type in the same paramaters over and over.  The program, rmovave, will not accept an answer file or I'd fix it that way.  Maybe what I want to do isn't possible? It seems like it should be.  Please help me as I have several hundred files to run through this program (and three others after that!!).  Thanks.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch File Q: Please Help Me!
« Reply #1 on: July 26, 2005, 12:56:44 PM »
If you are using XP or 2000 try:
Code: [Select]

set /p var=promptstring


If you are using DOS or Win9x there is a nifty little utility. Answer allows you to prompt for user data and store it in the environment space. Each time it runs the environment variable is overwritten, so be sure to save each value to your own variables. Put into a directory along your path and you can use it anywhere.

Hope this helps. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

dosnovice

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #2 on: July 26, 2005, 01:16:28 PM »
Thanks for the help sidewinder.  I am using command prompt in windows xp.  You have to forgive me, I'm really new to using dos.  After I add your code should I put /p before each line of prompt?  Thanks again.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch File Q: Please Help Me!
« Reply #3 on: July 26, 2005, 01:24:29 PM »
Yes. Something like this:

Code: [Select]

set /p input=Enter name of input file:
set /p output=Enter name of output file:


You can then use the %input% and %output% variable names in your batch file.

Good luck. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

dosnovice

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #4 on: July 26, 2005, 01:40:10 PM »
I tried what you told me to do but the /p lines don't answer the prompts in my program (rmovave).  I think I'm in a bit over my head.  I just learned what a .bat file is today.  I guess I have to run all hundred plus files I have manually.  

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch File Q: Please Help Me!
« Reply #5 on: July 26, 2005, 02:16:12 PM »
My mistake, I misread your question. Some programs expect parameters on the command line. Some programs can read redirected input. Some programs will accept input thru the pipe and some programs can read an answer file. What program are you referring to?

:'(
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

dosnovice

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #6 on: July 26, 2005, 02:26:11 PM »
The program is called Rectified Moving Average (rmovave for short).  I don't think it's very common.  I believe it's written in Pascal if this helps. I'm using it to smooth waveform files (people's heartbeats or ECGs) to isolate a certain part of the wave.  I know it will not accept an answer file.  Does that mean that my hope of creating a batch file to make my life easier is in vain?    

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch File Q: Please Help Me!
« Reply #7 on: July 26, 2005, 02:48:07 PM »
I couldn't find any info on the net for your program. Does it not have any documentation about how to run it. I would think the program would take a command line parameter that points to the input file. You might be able to build a loop, processing each file thru your program.

If you could post how you run it from the command line, perhaps someone could find a solution.

Let us know. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

dosnovice

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #8 on: July 26, 2005, 02:57:14 PM »
Okay, this is my last post of the day 'cause it's time to get on the subway and go home.  The program runs like this, step by step:
rmovave [starts program]
imput file?
output file?
sampling rate?
time constant to use?
signal ground?
start at what sec?
end at what sec?
I hope this answers your question.  I desperatly want to build that loop your talking about.  I spent the entire day answering these prompts over and over again.  All answers were the same with the exception of input and output file (obviously).  Thanks for your help.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch File Q: Please Help Me!
« Reply #9 on: July 26, 2005, 06:55:15 PM »
Since the program is calling for data, all that needs to be done is to redirect the STDIN device (the keyboard) to a file. And a little smoke and mirrors of course ;D

Code: [Select]

@echo off
for /f "tokens=1-2 delims=. " %%a in ('dir /b /s path\*.dat') do (
     echo %%a.%%b       > answer.dat
     echo %%a.out      >> answer.dat
     echo samplingrate >> answer.dat
     echo timeconstant >> answer.dat
     echo signalground >> answer.dat
     echo startsec     >> answer.dat
     echo endsec       >> answer.dat
     path\rmovave < answer.dat
     )


How does it work?

1) gets a list of all the input files; the *.dat is the filter. (please tell me they're in the same directory)
2) sets up responses to program queries
3) runs program using redirected STDIN device, the answer.dat file

Output files will have same name as input file with a .out extension. Change if need be.

You need to fixup path\ and *.dat Make sure the path\ points to the input and output files and the filter matches your input file extensions; Also put real values for sampling rate thru endsec and fixup the path\ to the rmovave program.

With any luck all your input files will be processed with no input from you.

Good luck. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

merlin_2

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #10 on: July 26, 2005, 08:05:27 PM »
Not to nick sidewinders thunder but i found this ,and its up to you!>http://www.softtreetech.com/i24x7.htm

dosnovice

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #11 on: July 27, 2005, 08:50:48 AM »
Thanks guys for all your help!  We're almost there, except for one problem.  My program (rmovave) doesn't like having the path ahead of the input and output file.  How can I alter sidewinder's code so that the path doesn't show up in the answer.dat file the batch file creates? I need to do this for both input and output.  You guys have been so helpful. Thanks again so much!  

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch File Q: Please Help Me!
« Reply #12 on: July 27, 2005, 09:08:51 AM »
Remove the /s switch from the dir command:

Code: [Select]

for /f "tokens=1-2 delims=. " %%a in ('dir /b path\*.dat') do (


If you are running the batch file from the directory where the input files and the rmovave is located, you don't need any path\ info. The output files will also be placed in the same directory.

Hope this helps. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

dosnovice

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #13 on: July 27, 2005, 09:23:55 AM »
IT WORKS!  Thanks so much sidewinder, you have no idea how much this helps me, along with everyone else in my office.  I'm going to try and add on to this file so that it will run the output through two more programs.  I'll probally have problems with that too, but now I have somewhere to start from.  Thanks again!

dosnovice

  • Guest
Re: Batch File Q: Please Help Me!
« Reply #14 on: July 27, 2005, 10:49:14 AM »
One more question.  I'm trying to apply the same code to use with two more programs.  The programs are sample (downsamples the sample rate of the file ie. from 500Hz to 5Hz) and int2drl (converts files to double realtime precision format).  I've created batch files to do this as a test (eventually I want to combine them all into one batch file) and I've run into some old problems.  I wrote the code out exactly the same, changed the values for input, changed the filter, and gave the answer file a new name.  Yet it doesn't want to use the .dat file to answer the program prompts as it so nicely does for rmovave.  Any ideas?  Thanks again!