当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > 一个扩展时间段的dir命令的vbs脚本

VBScript
adodb.stream读文件到数组的代码
利用sql语句复制一条或多条记录
百度空间备份脚本baidublogbak.vbs代码分析
vbs版sql查询分析器lcx作品
最新版利用CDO.Message做的vbs下载者
PDF的VBS小程序代码
算阶乘的vbs小程序
vbs后台运行bat删除自身的代码
VB6 ByVal ByRef函数调用
一段提取用户名和md5的vbs代码
vbs fso跨盘移动文件夹的怪问题
vbs删除文本文件的行的函数
显示运行对话框内保存的命令历史的vbs
emule自动关机脚本
IE中用VBScript不提示直接打印的代码
vbs引用另一个vbs的代码
VBScript 剪贴板抓取URL并在浏览器中打开
奇特的js写法,或许可以用来加密躲杀毒软件什么的
自动写入文件上传到指定服务器SoftwareMeteringCLS.vbs源码
一个查看局域网在线IP的vbs脚本

VBScript 中的 一个扩展时间段的dir命令的vbs脚本


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-11   浏览: 85 ::
收藏到网摘: n/a

CMD下的dir好像没法列出从某段时间到某段时间的文件,所以写了这个小东东,方便根据我们的要求显示数据 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 = "搜索完成!" & vbCrLf & "共找到文件:" & FileTotal & "个." & vbCrLf & "共搜索目录:" & DirTotal & "个." &vbcrlf&"文件总数大小"&FormatNumber(FileTotalsize/1024,0)&"kB"& vbCrLf & "用时:" & TimeSpend & "秒."
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