setArg=Wscript.Arguments
IfArg.Count=0then
Wscript.echochr(9)&chr(9)&space(4)&"Xdirv0.1"
Wscript.echo""
Wscript.echochr(9)&"cscriptdir.vbspathtime1time2ext"
Wscript.echochr(9)&"cscriptdir.vbsd:test2008010120080430doc"
Wscript.Quit
EndIf
Path=Arg(0)
Time1=Arg(1)
Time2=Arg(2)
Ext=Arg(3)
FileTotal=0
DirTotal=0
FileTotalsize=0
TimeSpend=Timer
myFindPath
TimeSpend=round(Timer-TimeSpend,2)
txtResult="搜索完成!"&vbCrLf&"共找到文件:"&FileTotal&"个."&vbCrLf&"共搜索目录:"&DirTotal&"个."&vbcrlf&"文件总数大小"&FormatNumber(FileTotalsize/1024,0)&"kB"&vbCrLf&"用时:"&TimeSpend&"秒."
wscript.echotxtResult
SubmyFind(ByValthePath)
Dimfso,myFolder,myFile,curFolder
Setfso=wscript.CreateObject("scripting.filesystemobject")
SetcurFolders=fso.getfolder(thePath)
DirTotal=DirTotal+1
IfcurFolders.Files.Count>0Then
ForEachmyFileIncurFolders.Files
IfInStr(1,LCase(Fso.GetExtensionName(myFile.Name)),ext)>0AndGtime(myFile.DateCreated)>Time1AndGtime(myFile.DateCreated)<Time2Then
wscript.echoFormatPath(thePath)&""&myFile.Name
FileTotal=FileTotal+1
FileTotalsize=FileTotalsize+myFile.size
EndIf
Next
EndIf
IfcurFolders.subfolders.Count>0Then
ForEachmyFolderIncurFolders.subfolders
myFindFormatPath(thePath)&""&myFolder.Name
Next
EndIf
EndSub
FunctionFormatPath(ByValthePath)
thePath=Trim(thePath)
FormatPath=thePath
IfRight(thePath,1)=""ThenFormatPath=Mid(thePath,1,Len(thePath)-1)
EndFunction
FunctionGtime(str)
str=FormatDateTime(str,2)
str1=Split(str,"-",-1,1)
Iflen(str1(1))=1thenstr11="0"&str1(1)
Iflen(str1(2))=1thenstr12="0"&str1(2)
Gtime=str1(0)&str11&str12
EndFunction