【发布时间】:2015-03-15 02:29:31
【问题描述】:
我已使用以下代码将 .cpp 文件合并到一个目录中。此代码是超级用户提出的问题的结果,但由于我的问题已被编辑,因此没有回复。所以请不要将此问题标记为重复.
@echo off
cd C:\test
echo ^<html^>^<head^>^<style^> pre {page-break-after: always;} ^</style^>^</head^>^<body^> >merged.html
for /r %%f in (*.cpp) do (
echo ^<pre^>
echo File Name : //Here i want the file name of each program without .cpp extension
echo Description :
echo Author : Name
echo Date : //Here i want the date associated with each file DD-MM-YYYY
echo.
type "%%f"
echo ^</pre^>
) >> merged.html
echo ^</body^>^</html^> >> merged.html
当前 Merged.html 文件
File name :
Desciption :
Author : Name
Date :
#include
int main()
{
.....
.....
.....
}
Then the second file on the next page .
上面的代码有问题
它省略了头文件名,即
在原始文件中我有#include,但在合并文件中 我只有#include。我猜问题是由于“”。
我需要什么
我需要在日期之后与合并文件中的每个程序文件关联的日期:(参见我上面的代码,阅读注释部分)。我还需要在文件名之后每个程序的文件名:如 abc(不带扩展名.cpp 文件)。
【问题讨论】:
-
所以你只需要知道如何获取文件最后修改的日期和无扩展名的文件名?那么这和合并有什么关系呢?
-
@SomethingDark 假设如果有 2 个文件 1.pgm_1.cpp date : 5-5-2015 和 2.pgm_2.cpp date : 2-3-2015 。现在在合并时,我在每个程序的顶部添加 4 行。考虑文件 1 的情况:文件名:(这里我需要不带扩展名 .cpp 的 pgm.cpp)然后描述:(我将在将其转换为 pdf 后填写)然后是作者:myName,最后是日期:(这里我需要日期 5-5-2015),就像第二个文件一样。
-
是的,但这本质上仍然是处理多个文件的情况,因为您对实际的合并过程没有问题。
-
我有很多 .cpp 文件,很难在每一页上添加日期和文件名。这就是我问这个问题的原因。
-
@SomethingDark 帮我找到解决办法
标签: batch-file cmd command command-prompt text-formatting