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

Author Topic: batch processes...  (Read 6353 times)

0 Members and 1 Guest are viewing this topic.

bhill4

    Topic Starter


    Greenhorn

    • Experience: Beginner
    • OS: Unknown
    batch processes...
    « on: February 11, 2011, 12:34:44 AM »
    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'  !!!


     

    polle123



      Rookie

      • Experience: Beginner
      • OS: Unknown
      Re: batch processes...
      « Reply #1 on: February 11, 2011, 08:15:35 AM »
      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 :)

      Salmon Trout

      • Guest
      Re: batch processes...
      « Reply #2 on: February 11, 2011, 10:23:49 AM »
      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



      polle123



        Rookie

        • Experience: Beginner
        • OS: Unknown
        Re: batch processes...
        « Reply #3 on: February 12, 2011, 11:57:31 PM »
        like i said, more elegant ways, tnx salmon :)