Can you please help me
I am trying to Create a Batch file what would read multiple files from a folder and copy only the first and last lines from each file to a New text or csv file.
The file extension differs as some of them are .log and some are .txt
I Have 2 batch files that would read first and last lines separately but I am not able to combine them; so that I have the file name, first line and Last line in a single line with pipe delimiter;
Any pointers would greatly be appreciated!
Thanks to Various Post in this forum I was able to find the below code
for %%a in (*.txt) do (
for /f "usebackq delims=" %%b in ("%%a") do if not defined first (
echo("%%a |" %%b
for %%F in (*.txt) do (
<nul set /p "=%%F |"
for /f %%N in ('type "%%F"^|find /c /v ""') do set /a skip=%%N
if !skip! gtr 0 set /a skip-=1
more +!skip! "%%F"
message edited by SridharCR