批量记录新行



非常简单的问题,我确信解决方案很容易,但我根本找不到解决方案。请原谅我对batch的理解有限,我是一个unix人。

我有一个批处理的for循环,它在用户定义的文件夹的内容上运行脚本。如果发生错误,脚本将向命令提示符输出一条消息。我正在通过

记录这些消息
"%UserProfile%DocumentsFoosterLogsfailed_log.txt" 2>&1  (
for /f %%f in ('dir /s/b %arg1%') do call R-PortableAppR-PortablebinRscript.exe Scriptsfooster_io.R %%f %arg2% 
)

现在,这个记录很好,但是每条消息都不换行地连接到下一条消息。如何插入换行符,使每条消息都有自己的行?

I have try:

"%UserProfile%DocumentsFoosterLogsfailed_log.txt" 2>&1/n
"%UserProfile%DocumentsFoosterLogsfailed_log.txt" 2>&1 /n
"%UserProfile%DocumentsFoosterLogsfailed_log.txt" 2>&1 echo.
"%UserProfile%DocumentsFoosterLogsfailed_log.txt" echo. 2>&1

并非所有的方法都能产生预期的结果。什么好主意吗?

看起来,您的fooster_io.R不会自己添加换行符。
但是你可以把"newline"进入for循环。

"%UserProfile%DocumentsFoosterLogsfailed_log.txt" 2>&1  (
for /f %%f in ('dir /s/b %arg1%') do (
R-PortableAppR-PortablebinRscript.exe Scriptsfooster_io.R %%f %arg2% 
echo(
)
)

我用echo(代替echo.,因为它更快,而且不会失败。

最新更新