I have the following command:
c:\run.exe >> c:\log.txt
I actually want:
c:\run.exe >> c:\log_19-07-2016.txt
Can it be done?
Thanks
I have the following command:
c:\run.exe >> c:\log.txt
I actually want:
c:\run.exe >> c:\log_19-07-2016.txt
Can it be done?
Thanks
I stole from Stack Overflow for you after discovering the old batch assets I had lying around used a different date format and therefore didn't give the right format. Add this to the top of your script:
for /f %%I in ('wmic os get localdatetime ^|find "20"') do set dt=%%I
REM dt format is now YYYYMMDDhhmmss...
set dt=%dt:~4,2%-%dt:~2,2%-%dt:~0,4%
set outfile = "c:\log_%dt%.txt"
Then use:
c:\run.exe >> %outfile%
instead of the other command.