Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 需要熟悉Windows批处理语法吗 我在Windows上编译了一个C++程序,我需要它来处理大量的我的数据文件。这些文件被命名为,例如,“x0000y”到“x9999y” > C++程序一次只取一个文件,创建每个文件的输出,保存某处,并终止。我不想硬编码的程序,因为我的数据集并不总是有相同数量的文件-并继续重新编译程序只是因为这是不酷的。所以我正在寻找一种快速的方法:批处理_Loops_Execution_Batch Processing - Fatal编程技术网

Loops 需要熟悉Windows批处理语法吗 我在Windows上编译了一个C++程序,我需要它来处理大量的我的数据文件。这些文件被命名为,例如,“x0000y”到“x9999y” > C++程序一次只取一个文件,创建每个文件的输出,保存某处,并终止。我不想硬编码的程序,因为我的数据集并不总是有相同数量的文件-并继续重新编译程序只是因为这是不酷的。所以我正在寻找一种快速的方法:批处理

Loops 需要熟悉Windows批处理语法吗 我在Windows上编译了一个C++程序,我需要它来处理大量的我的数据文件。这些文件被命名为,例如,“x0000y”到“x9999y” > C++程序一次只取一个文件,创建每个文件的输出,保存某处,并终止。我不想硬编码的程序,因为我的数据集并不总是有相同数量的文件-并继续重新编译程序只是因为这是不酷的。所以我正在寻找一种快速的方法:批处理,loops,execution,batch-processing,Loops,Execution,Batch Processing,麻烦来了:我在尝试获取正确有效的批处理语法时遇到困难。有人能给我看一下批处理版本中的以下伪代码吗 for (int i = 0; i < lastFile; i++){ String filename; /* Because the files are named "x0000y", "x0034y", etc. We need to put in all the extra 0s in the string if i is less than 100

麻烦来了:我在尝试获取正确有效的批处理语法时遇到困难。有人能给我看一下批处理版本中的以下伪代码吗

for (int i = 0; i < lastFile; i++){

    String filename;

    /*
    Because the files are named "x0000y", "x0034y", etc. 
    We need to put in all the extra 0s in the string if i is less than 1000.
    */
    String numberedString = convertNumToFourDigit(i);

    filename = "myFileName" + numberedString + "Footer";       

    /*
    execute the program with the respective filename.
    */
    execute("MyProgram.exe " + filename);

}
for(int i=0;i
这是您在.bat文件中所需的全部内容,用于针对当前目录中的所有文件运行程序

for %%I IN (*) DO ( MyProgram.exe %%I )
如果数据文件位于具有扩展名的子目录中,下面是一个示例

for %%I IN (subdir\*.dat) DO ( MyProgram.exe %%I )
如果您只需要x0000y格式的文件,那么这就可以了

for %%I IN (x????y) DO ( MyProgram.exe %%I )

这些文件将按照文件系统提供名称的任何顺序处理数据文件。

实际上,我希望程序只处理文件“x0000y”到“x9999y”,而不是目录中的所有文件。我添加了第三个文件,以便为您仅过滤这些文件。每个问号代表一个未知字符。您还可以用一个asterix替换所有四个。