如何在命令提示符下进行“ for”循环? [英] How do I make a 'for' loop in the command prompt?

查看:338
本文介绍了如何在命令提示符下进行“ for”循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用执行图像处理的命令行程序,并且需要在整个图像文件夹上运行相同的命令。我听说我可以在命令提示符下运行循环,但是我在网上看到了各种各样的示例,因此无法弄清楚语法。文件夹中的图像一直标记为 single0.pgm,single1.pgm,single2.pgm,...,一直到single39.pgm。我需要运行的命令是:

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

我需要为每张照片做到这一点。在C语言中,这只是一个简单的 for 循环,例如

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?

推荐答案

我知道了!对于任何好奇的人,循环是:

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

这篇关于如何在命令提示符下进行“ for”循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆