请脚本编程高手帮个小忙,一个wsf的小程序,很急很急,在线等,标题搞长…………长一点吧……求大神帮助
我想统计TXT文本行数,然后网上有一小段程序,貌似vbs的,然后这段程序的结果输出在msgbox里,但是我要的数据很多,msgbox有个缺点就是不能把结果搞出来,我一个个...
我想统计TXT文本行数,然后网上有一小段程序,貌似vbs的,然后这段程序的结果输出在msgbox里,但是我要的数据很多,msgbox有个缺点就是不能把结果搞出来,我一个个手打要很久,所以请高手帮忙让结果输出在能CTRLc-CTRLv的地方! <job id="HowManyLines"> <script language="VBScript"> Const ForReading = 1 Dim objFSO, fold, f, strMsg, fileNames(100), objFile, lineCount(100),files,i set objFSO = CreateObject("Scripting.FileSystemObject") set fold = objFSO.GetFolder("C:\Documents and Settings\") set files = fold.Files For Each f in files If objFSO.GetExtensionName(f) = "txt" 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 = "" For i = 0 To UBound(fileNames) If fileNames(i)<>"" Then strMsg = strMsg & fileNames(i) & ":" & lineCount(i) strMsg = strMsg & Chr(13) End If Next MsgBox(strMsg) </script> </job>
展开
展开全部
On Error Resume Next Const ForReading = 1 Dim objFSO, fold, f, strMsg, fileNames(100), objFile, lineCount(100),files,i Dim Savename set objFSO = CreateObject("Scripting.FileSystemObject") set objWSH=createobject("WScript.Shell") set fold = objFSO.GetFolder( "C:\" ) set files = fold.Files For Each f in files If objFSO.GetExtensionName(f) = "txt" 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 = "" For i = 0 To UBound(fileNames) If fileNames(i)<>"" Then strMsg = strMsg & fileNames(i) & ":" & lineCount(i) strMsg = strMsg & Chr(13) End If Next Savename = objFSO.GetFolder(".").Path & "\" Set txt=objFSO.opentextfile(Savename & "1.txt",8) txt.writeline vbcrlf & strMsg txt.close
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询