Set Arg = wscript. Arguments
If Arg. Count = 0 then
Wscript. Echo CHR (9) & CHR (9) & Space (4) & "xdir v0.1"
Wscript. Echo ""
Wscript. Echo CHR (9) & "cscript dir. vbs path time1 time2 Ext"
Wscript. Echo CHR (9) & "cscript dir. vbs D: \ test 20080101 20080430 Doc"
Wscript. Quit
End if
Path = Arg (0)
Time1 = Arg (1)
Time2 = Arg (2)
EXT = Arg (3)
Filetotal = 0
Dirtotal = 0
Filetotalsize = 0
Timespend = Timer
Myfind path
Timespend = round (timer-timespend, 2)
Txtresult = "search complete! "& Vbcrlf &" found files: "& filetotal. "& vbcrlf &" total search directories: "& dirtotal. "& vbcrlf &" total file size "& formatnumber (filetotalsize/, 0) &" kb "& vbcrlf &": "& timespend &" seconds."
Wscript. Echo txtresult
Sub myfind (byval thepath)
Dim FSO, myfolder, myfile, curfolder
Set FSO = wscript. Createobject ("scripting. FileSystemObject ")
Set curfolders = FSO. getfolder (thepath)
Dirtotal = dirtotal + 1
If curfolders. Files. Count> 0 then
For each myfile in curfolders. Files
If instr (1, lcase (FSO. getextensionname (myfile. Name), ext)> 0 and gtime (myfile. datecreated)> time1 and gtime (myfile. datecreated) <time2 then
Wscript. Echo formatpath (thepath) & "\" & myfile. Name
Filetotal = filetotal + 1
Filetotalsize = filetotalsize + myfile. Size
End if
Next
End if
If curfolders. subfolders. Count> 0 then
For each myfolder in curfolders. subfolders
Myfind formatpath (thepath) & "\" & myfolder. Name
Next
End if
End sub
Function formatpath (byval thepath)
Thepath = trim (thepath)
Formatpath = thepath
If right (thepath, 1) = "\" then formatpath = mid (thepath, 1, Len (thepath)-1)
End Function
Function gtime (STR)
STR = formatdatetime (STR, 2)
Str1 = Split (STR, "-",-1, 1)
If Len (str1 (1) = 1 then str11 = "0" & str1 (1)
If Len (str1 (2) = 1 then str12 = "0" & str1 (2)
Gtime = str1 (0) & str11 & str12
End Function