1.

Solve : batch processes...?

Answer»

Hello, I am a semi-newbie to DOS command prompt.

I have a PROGRAM "A.exe" that reads commands and data from a pre-existing text file called "input_1.txt".
This produces an output file, called "out_1.txt"

This is what I manually type at the command prompt if I just want to do one step
(for example, provide "input_1.txt" to "A.exe", which results in "out_1.txt" as output:

C:\> A.exe input_1.txt > out_1.txt

I want to run a bunch of these, one at a time (up to, say, "A.exe input_99 > out_99.txt")
Note: each process takes about 1 hour of computing time.

How can I automate this process, so that I don't have to manually type commands at the prompt for each of the 99 steps?
Please help this 'newbie' !!!


Ok, This batch file presumes all your files are named input_something, where something is a number going from 1-99

Code: [Select]@echo off
set num=1
:A
A.exe input_%num%.txt > out_%num%.txt
set /a num=%num%+1
if %num% EQU 100 goto B
goto A
:B
exit

there are more elegant ways to do this, using the for command, but this is easy to UNDERSTAND for you, and easy modifiable Code: [Select]@echo off
setlocal enabledelayedexpansion
set /p start="FIRST number ? "
set /p finish="last number ? "
set step=1
for /l %%N in (%start%,%step%,%finish%) do (
echo !date! !time! start processing input_%%N.txt
A.exe input_%%N.txt > out_%%N.txt
)
echo Finished processing
echo.
pause


LIKE i said, more elegant ways, tnx salmon



Discussion

No Comment Found