Run a batch command for every file in a directory

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?


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