I’m writing a Windows batch file that will purge logs older than 90 days. How can I concatenate the outputs of the commands so that they appear in one line? I also want to append this output to a file later. My batch file so far is:
@echo off
time /t && echo "--" && date /t && echo " -I- Purging " && FORFILES /P "D:\Logs" /M *.log /D -90 /C "cmd /c echo @file @fdate"
rem FORFILES that will purge the files
and this outputs:
12:08
--
14/08/2012
-I- Purging
"<filename>" 02/08/2012
"<filename>" 30/07/2012
How can I concatenate these outputs? Thanks.
If you want to concatenate the lines in the output, you can set
CMD_STRto be your desired command, and use afor /floop, like so:The loop iterates through the lines of the output and appends them one by one to
CONCAT_STR.