0

i found these two similar questions: Redirect stdout to a file and add a timestamp and How to add timestamp to STDERR redirection to redirect stdout to a file.

I want to add a timestamp when the line is written to the file. At the moment I wrtie the log file like this:

START cmd /c %PATH_STLink-OPENOCD%\openocd.exe -f %CD%\%CFG_File% -s %PATH_SUPPORTFILES% -d0 ^> output.txt

It would be nice, when the output could look like this (using %date% and %time%). Hopefully this is possible:

[10.03.2022, 16:11:40,45]output of openocd.exe
[10.03.2022, 16:11:42,21]output of openocd.exe
[10.03.2022, 16:11:43,65]output of openocd.exe

Thank you very much!

1 Answers1

0
<NUL >output.txt set /p=[%date%, %time%]
start ... >>output.txt

should put the prompt for the set/p into the new file output.txt with no newline; then append the data you want.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • Thank you! :) When I use your example, then it will set the date and time only in the first line. But I want that the timestamp should set to every output, which the OpenOCD.exe write to the stdout. – bastian7032 Mar 10 '22 at 20:11