I tried to copy one file to another from starting line upto a limit. ie., line 1 to 10(file1.txt)->file2.txt but while writing "!" is skipped. what can i do for to solve it. Any help will be thankful.
The loop for that function is given below.
%NF%-> new file.
%EF%-> existing file
%1% -> line number(passed from another part)
:_doit
findstr /N /R "." %EF%|findstr /B /C:"%1:">nul
if errorlevel 1 (
echo. >>%NF%
) else (
for /f "tokens=1 delims=" %%a in ('findstr /N /R "." %EF%^|findstr /B /C:"%1:"') do (
if [%%a] EQU [] (
echo. >>%NF%
) else (
echo %%a >>%NF%
)
)
)
If you can download tools, you can use GNU win32 gawk
gawk.exe "NR>10{exit}1" file1 > file2
And you can take a look at this thread here that is similar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With