文件名保存为.wsf文件即可分析文件夹中每个文件的行数

<job id="HowManyLines">

<script language="VBScript">

Const ForReading = 1

Dim objFSO, fold, f, strMsg, strMsgCount,fileNames(100), objFile, lineCount(100),files,i

set objFSO = CreateObject("Scripting.FileSystemObject")

set fold = objFSO.GetFolder("C:\Users\wangjingzhi\Desktop\审计接口\导出\DatabaseScript\Bizsys\")

set files = fold.Files


For Each f in files

If objFSO.GetExtensionName(f) = "sql" Then

Set objFile = objFSO.OpenTextFile(f, ForReading)

Do While objFile.AtEndOfStream <> True

objFile.ReadLine

lineCount(i) = lineCount(i) + 1

Loop

objFile.Close

fileNames(i) = f.Name

i = i + 1

End If

Next


strMsg = ""
strMsgCount=0
For i = 0 To UBound(fileNames)

If fileNames(i)<>"" Then

strMsg = strMsg & fileNames(i) & ":" & lineCount(i)

strMsg = strMsg & Chr(13)
strMsgCount=strMsgCount +lineCount(i)
End If

Next

MsgBox(strMsg)
MsgBox(strMsgCount)
</script>

</job>

 

posted @ 2016-01-19 14:52  银杏叶儿  Views(193)  Comments(0Edit  收藏  举报