@echo off
set SrcFile=C:\a.txt
set DstFirst=C:\b.txt
set DstLast=C:\c.txt
type nul>"%DstFirst%"
type nul>"%DstLast%"
for /f "tokens=1-3 delims= " %%a in ('findstr .* "%SrcFile%"') do (
echo %%a>>"%DstFirst%"
echo %%c>>"%DstLast%"
)
@echo off&setlocal
for /f "delims=" %%a in (a.txt) do (
for %%b in (%%a) do (
if not defined batch (echo\%%b>>first.txt & set batch=cn-dos) else (set word=%%b)
)
set batch=
if defined word call echo\%%word%%>>last.txt
)
@echo off& setlocal enabledelayedexpansion
for /f "tokens=1*" %%a in (a.txt) do (
echo\%%a>>first.txt
for %%c in (%%b) do set last=%%c
echo\!last!>>last.txt
)