当前位置: 移动技术网 > IT编程>脚本编程>VBScript > 一个扩展时间段的dir命令的vbs脚本

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

灵光守护者攻略,av达人,我们约会吧20130313

核心代码

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 

这篇文章就介绍到这,希望大家以后多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网