I need the batch code to copy the FIRST line of multiple text files into a new text file and append original filenames to each line, and if possible a way of editing the batch code to any LINE number one wants.
Thanks
I need the batch code to copy the FIRST line of multiple text files into a new text file and append original filenames to each line, and if possible a way of editing the batch code to any LINE number one wants.
Thanks
This uses a helper batch file called findrepl.bat
from - https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat
Place findrepl.bat
in the same folder as the batch file or on the path.
@echo off
set linenum=1
for %%a in (*.txt) do (
type "%%a"|findrepl /o:%linenum%:%linenum% >>tmp.tmp
)
move /y tmp.tmp "Result.txt"
@ECHO OFF &SETLOCAL
for %%a in (*.txt) do (
set "line="
set /p "line="<"%%~a"
SETLOCAL ENABLEDELAYEDEXPANSION
echo(!line!
endlocal
)