10
3
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?
10
3
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?
14
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
Hi! It works with this: for %f in (*) do command.jar %f
Really really thanks! :) – None – 2010-03-05T09:03:00.817
@E_M: Edited my answer to make that clear. – Bobby – 2010-03-05T09:03:52.813
This is because you have to escape the % in a batch file. To be safe you should first append 'echo' to the beginning of the command to see what exactly will be executed. – mrexodia – 2018-09-23T15:12:59.870