你可以这样做。该解决方案在字符串大小检查方面还有很多不足之处,但基础是这个。
您输入路径和文件编号基数以及要处理的批次中的文件数。
#include <stdio.h>
int main (int argc, char *argv[])
{
unsigned basenum, numfiles, i;
char inname[1000], outname[1000];
if (argc < 5)
return 1;
sscanf(argv[3], "%u", &basenum);
sscanf(argv[4], "%u", &numfiles);
for (i=0; i<numfiles; i++) {
sprintf (inname, "%s/%03u.png", argv[1], basenum + i);
sprintf (outname, "%s/%03u.blah", argv[2], basenum + i);
//convertimg (inname, outname);
printf ("Processed %s to %s\n", inname, outname);
}
return 0;
}
程序输入
test aaa dest/bbbb 100 10
程序输出
Processed aaa/100.png to dest/bbbb/100.blah
Processed aaa/101.png to dest/bbbb/101.blah
Processed aaa/102.png to dest/bbbb/102.blah
Processed aaa/103.png to dest/bbbb/103.blah
Processed aaa/104.png to dest/bbbb/104.blah
Processed aaa/105.png to dest/bbbb/105.blah
Processed aaa/106.png to dest/bbbb/106.blah
Processed aaa/107.png to dest/bbbb/107.blah
Processed aaa/108.png to dest/bbbb/108.blah
Processed aaa/109.png to dest/bbbb/109.blah