Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 13 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.