资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

如何使用vbs实现一个扩展时间段的dir命令-创新互联

这篇文章主要介绍了如何使用vbs实现一个扩展时间段的dir命令,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

成都创新互联公司是一家专业提供十堰郧阳企业网站建设,专注与成都网站建设、成都做网站、H5高端网站建设、小程序制作等业务。10年已为十堰郧阳众多企业、政府机构等服务。创新互联专业网络公司优惠进行中。

核心代码

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) 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

感谢你能够认真阅读完这篇文章,希望小编分享的“如何使用vbs实现一个扩展时间段的dir命令”这篇文章对大家有帮助,同时也希望大家多多支持创新互联网站建设公司,,关注创新互联行业资讯频道,更多相关知识等着你来学习!


本文题目:如何使用vbs实现一个扩展时间段的dir命令-创新互联
文章地址:http://cdkjz.cn/article/ccieoc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220