Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Java program working with this syntax:

command.jar namefile

I have to run this program for 1600 files in a directory. How can I run this command for every file automatically?

Is there a DOS batch command? Or another way?

share|improve this question
up vote 14 down vote accepted

The easiest way is by far to simply run a for loop over all the files. The good thing is that the set (the input for the for-loop) does accept the same wildcards like the regular cmd.

For use in a batch file:

FOR %%f IN (*) DO command.jar %%f

For use from the command line:

FOR %f IN (*) DO command.jar %f
share|improve this answer
    
Hi! It works with this: for %f in (*) do command.jar %f Really really thanks! :) – E_M Mar 5 '10 at 9:03
    
@E_M: Edited my answer to make that clear. – Bobby Mar 5 '10 at 9:03

You must log in to answer this question.