Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a 'for' loop in the command prompt?

I'm working with a command-line program that does image-processing, and I need to run the same command on an entire folder of images. I have heard that I can run loops in the command prompt, but I have seen all sorts of different examples online and can't figure out the syntax. The images in the folder are labled "single0.pgm, single1.pgm, single2.pgm,..." all the way to single39.pgm. The command I need to run is:

DebayerGPU.exe -demosaic DFPD_R -CPU -pattern GRBG -i single0.pgm -o single0.ppm

And I need to do that for every picture. In C it is just a simple for loop like

for (int j = 0; j<40; j++) {
    DebayerGPU.exe -demosaic DFPD_R -CPU -pattern GRBG -i singlej.pgm -o singlej.ppm
}

How do I do that in the command prompt?

like image 995
singmotor Avatar asked Dec 04 '25 03:12

singmotor


1 Answers

I figured it out! For anyone curious, the loop is:

for %a in (0 1 2 3 4 5 6 7 8 9 10 11 1
2 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
39) do DebayerGPU.exe -demosaic DFPD_R -CPU -pattern GRBG -i single%a..pgm -o si
ngle%a.ppm
like image 61
singmotor Avatar answered Dec 06 '25 23:12

singmotor