ScanFiles脚本

Function ScanFolder(TF,WORD)
   Dim Fso,TFCount
   TFCount=0
   Set Fso = CreateObject("Scripting.FileSystemObject")
   Set FDS = Fso.GetFolder(TF)
   For Each FD in FDS.subFolders
 Call ScanFolder(FD,WORD)
       For Each F in FSO.GetFolder(FD).Files
 IF CheckFileExt(F.Path)=True then
  IF ScanWord(F.Path,WORD)=True Then Wscript.Echo F.Path
 End IF
 Next
   Next
End Function

Function ScanWord(pFile,WORD)
 IF Instr(ReadText(pFile),WORD) Then ScanWord=True:Exit Function
 ScanWord=False  
End Function

Function ReadText(pFile)
   Dim FSO,F
   Set FSO = CreateObject("Scripting.FileSystemObject")
   Set F = FSO.OpenTextFile(pFile,1,True)
   ReadText=F.ReadAll
End Function

Function CheckFileExt(Fname)
   Dim FileExtStr,FileExt
   FileExtStr=Right(Fname,Len(Fname)-InstrRev(Fname,".",-1,1)+1)
 CheckFileExt=False
   FileExt=".c|c.h"
   FileExt=Split(FileExt,"|")
   For I=0 to Ubound(FileExt)
 IF Instr(Fname,FileExt(I)) Then CheckFileExt=True:Exit Function
   Next
End Function
'====================Start===============================
IF Wscript.Arguments.Count<2 Then
Wscript.Echo "┌┄┄┄┄┄┐┌┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐"&vbCrlf
Wscript.Echo "┆参数不对!┆┆ScanFolder.Vbs By Liou QQ:5172388 http://cnLiou.cn┆"&vbCrlf
Wscript.Echo "└┄┄┄┄┄┘└┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┘"&vbCrlf
Wscript.Quit
End IF
ScanFolder Wscript.Arguments(0),WScript.Arguments(1)

 

转载于:https://www.cnblogs.com/cnLiou/archive/2005/07/26/200548.html

你可能感兴趣的:(ScanFiles脚本)