Jeff Moden (6/14/2009)
You've added a line of code the OP didn't have in the original problem and that new line is the one responsible for the incorrect operation.
echo %date% %time% > "%temp%\output.txt
You've neglected to use ">>" in that line of code and that's what resets file. 😉
Correct, I reset the file between the runs, to demonstrate the effects of the two different methods. If the OP wants the file reset between runs, then use this line. If not, then get rid of it.
But the point was that with using the "-o" in the first part, the file is reset for every file being processed. Which is the behavior that the OP was trying to get rid of.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes