Script processing under Windows

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.