 <p><code>file.log</code> is the input file here. I've used Endoro's techniques but with some small changes.</p> <pre><code>@echo off setlocal enabledelayedexpansion ( echo Disk State Raw_Capacity User_Capacity for /f "usebackq delims=" %%a in ("file.log") do ( set "line=%%a" if /i "!line:Disk:=!" neq "!line!" &lt;nul set/p"=!line:*Disk:=! " if /i "!line:State=!" neq "!line!" &lt;nul set/p"=!line:*State:=! " if /i "!line:Raw=!" neq "!line!" &lt;nul set/p"=!line:*Capacity:=! " if /i "!line:User=!" neq "!line!" &lt;nul set/p"=!line:*Capacity:=!"&amp;echo( ) )&gt;"output file.txt" </code></pre>