The company needs to deal with the SQL script problem, each file deleted the last 3 lines, the number of files, it is someone else's work, but he can not solve, I help to see the next, finally resolved, more than the online speed much faster, mainly understand for this command, will produce serial number, and do not have to produce a serial number alone, That's a lot of trouble.
for/f "tokens=*"%%d in (' dir/ad/b ') do (
 CD%%d
&NBSP ; for/f "tokens=*"%%f in (' dir/b *.sql ') does (
FINDSTR/C: "Use paradb;" F && Goto fir_end
echo use paradb; > temp.temp
; echo. >> temp.temp
type "%%f" >> temp.temp
del "%%f"
ren temp.temp "%%f"
: fir_ End
rem "End One Cir"
)
CD:
)
: sec
Set Errorlevel=0
for/f "tokens=*"%%f in (' dir/a-d/b *.sql ') does (
If "%%f" = = "Histable.sql" (
FINDSTR/C: "Use Hisdb;"%%f && Goto Sec_end
echo Use HISDB; > temp.temp
) Else (
FINDSTR/C: "Use paradb;"%%f && Goto Sec_end
echo Use PARADB; > temp.temp
)
Echo. >> temp.temp
Type "%%f" >> temp.temp
Del "%%f"
ren temp.temp "%%f"
: Sec_end
REM "End One Cir"
)
@echo off
Call:delline Xxx.sql 1
Goto EOF
:d Elline
Set file=%1
for/f "tokens=2 delims=:"%%i in (' Find/c/V ". *"%file% ") do set/a res=%%i-%2
(for/f "tokens=1* delims=:"%%a in (' findstr/n. *%file% ') do (
If%%a geq%res% goto MOV//This place know%a, skill full mark, beginner's people do not know, tried for a long time to know.
echo.%%b)) > Temp.temp
Goto EOF
: MOV
del/f/q%file%
ren temp.temp%file%
Goto EOF
: EOF
Script processing under Windows