[英]Batch Logging New Line
Pretty simple problem which I am sure the solution is easy, but I simply cannot find the solution anywhere.非常简单的问题,我相信解决方案很容易,但我根本无法在任何地方找到解决方案。 Please forgive my limited understanding of batch, I am a unix person.请原谅我对batch的理解有限,我是unix的人。
I have a for
loop in batch which runs a script on the contents of a user-defined folder.我有一个批量循环for
它在用户定义的文件夹的内容上运行脚本。 If an error occurs, the script will output a message to the command prompt.如果发生错误,脚本将 output 一条消息发送到命令提示符。 I am logging these messages by我正在记录这些消息
"%UserProfile%\Documents\Fooster\Logs\failed_log.txt" 2>&1 (
for /f %%f in ('dir /s/b %arg1%') do call R-Portable\App\R-Portable\bin\Rscript.exe Scripts\fooster_io.R %%f %arg2%
)
Now, this logs just fine, but each message is concatenated to the next without a line break.现在,这个记录很好,但是每条消息都连接到下一条消息而没有换行符。 How would I insert a line break such that each message gets its own line?我将如何插入换行符以使每条消息都有自己的行?
I have tried:我试过了:
"%UserProfile%\Documents\Fooster\Logs\failed_log.txt" 2>&1/n
"%UserProfile%\Documents\Fooster\Logs\failed_log.txt" 2>&1 /n
"%UserProfile%\Documents\Fooster\Logs\failed_log.txt" 2>&1 echo.
"%UserProfile%\Documents\Fooster\Logs\failed_log.txt" echo. 2>&1
All do not produce the desired results.所有这些都不会产生预期的结果。 Any ideas?有任何想法吗?
It seems, that your fooster_io.R
doesn't add newlines by itself.看来,您的fooster_io.R
本身并没有添加换行符。
But you can place the "newline" into the for-loop.但是您可以将“换行符”放入 for 循环中。
"%UserProfile%\Documents\Fooster\Logs\failed_log.txt" 2>&1 (
for /f %%f in ('dir /s/b %arg1%') do (
R-Portable\App\R-Portable\bin\Rscript.exe Scripts\fooster_io.R %%f %arg2%
echo(
)
)
I'm using echo(
instead of echo.
, because it's much faster and it doesn't fail.我正在使用echo(
而不是echo.
,因为它更快而且不会失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.