I wrote a simple batch file that search for a specific string.
forfiles /S /M TraceLog-* /d +%SearchDate% /c "cmd /c findstr /c:\"Not enough disk space to save focus debug data.\" @path" >> %FileName%
Is there a way to stop the run so the output file will contain only a single message of "Not enough disk space to save focus debug data". That means - if the above string was found - stop the loop.
The
forfilescommand does not provide a feature to terminate the loop once a certain condition is fulfilled.However, you could instead let the loop finish but write its output to a temporary file, whose first line you copy into the target log file afterwards:
This code (mis-)uses
set /Pintended to prompt a value from the user for reading the first line of a file in combination with input redirection<.