batch-file - TYPE 命令问题 - 批处理文件

标签 batch-file types command

嗨,我正在尝试使用 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/

相关文章:

windows - 在文件名 + Robocopy 日志记录中创建具有当前日期的文件

Kotlin - Void vs. Unit vs. Nothing

php - 将大文件分成两半

Linux 文件夹所有文件昨天修改

list - 在 Haskell 中格式化列表输出?

c# - 单击按钮MVVM时获取commandparameter值

windows - 在FOR循环中通过复杂的调用检索%ERRORLEVEL%

shell - 构建批处理文件以按顺序运行 exe 文件

batch-file - Windows 2000 说超时不是命令或批处理文件

javascript - Array.reduce 奇怪的行为