for /f "tokens=1* delims=:" %%i in ('type "%f%%n%%g%"^|findstr /n .*') do (set /a x+=1)
for /f "tokens=1* delims=:" %%i in ('type "%f%%n%%g%"^|findstr /n .*') do (set /a x-=1
if not "%%j"=="" (echo %%j>>%f%%n%a.ctl)
if !x!==%L% (goto :next))
:next
ren %n%%g% %n%_old%g%
ren %n%a.ctl %n%%g%
del %n%_old%g%
rem -------------