Redirect DOS Output Only if there is Output

Viewed 2179

I have a series of lines in a batch file (.bat) running on a Windows machine, e.g.:

start /b prog.exe cmdparam1 cmdparam2 > test1.txt
start /b prog.exe cmdparam1 cmdparam2 > test2.txt

Sometimes proj.exe returns nothing (empty) instead of useful data. In those cases I want to not generate a text file, is this something easily doable on the batch file side of things? The current behavior is that a text file is always created, in the case of empty output it's just a blank file.

2 Answers
Related