使用g ++编译并运行许多不同的项目

时间:2018-08-26 05:16:55

标签: c++ batch-file g++

首先,我在互联网上进行搜索,但找不到能够执行我想要的功能的东西。

在我早期的编程工作中(例如400多个),我有大量的C ++ / C / C#项目,最近我决定将它们挖掘出来。

文件夹结构:

-Projects
    -Project_1
        main.cpp
        //random other cpp/c/h files
     -Project_2
        main.cpp
        ....

有些项目被放弃或已被更新(我的旧计算机文件系统糟透了),我希望能够通过批处理或可能的c ++来执行类似于此伪代码的操作。

For each folder in projects
    get all cpp/h files and copy them to new folder inside a new directory called Processed
    attempt g++ compile (i'm going to ignore C# for now)

    if g++ was successful:
        run the executable/save output to output.txt

    if g++ not successful:
        output g++ failure message to errors.txt

有人知道我将如何实现这一目标吗?我试图找到问题的答案,但到目前为止,我只能找到如何列出目录中的所有文件夹,例如:

for /d %%D in (*) do echo %%~fD


REM run executable and output to file
main.exe > output.txt

0 个答案:

没有答案