嗨,我正在尝试使用 TYPE 命令将输出保存到文件中,例如:
type %Destination%\buildInfo.xml >> Logs\%Envlog% %Date% %Time%
其中 Envlog = logging.log
这不会发生你知道为什么吗?
请注意 buildInfo.xml 永远不会为空。
最佳答案
尝试添加引号:
type %Destination%\buildInfo.xml >> "Logs\%Envlog% %Date% %Time%"
但是,我不认为这会给你你想要的,因为这最终会像“Logs\logging.log 20131231 04:33”
使用 this answer作为引用,您可以执行以下操作(在这种情况下我没有使用环境变量,如果名称始终为 logging.log,则不确定您是否需要它):
set hr=%time:~0,2%
if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
type %Destination%\buildInfo.xml >> Logging_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%.log
关于batch-file - TYPE 命令问题 - 批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19707768/