服务器之家

服务器之家 > 正文

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

时间:2020-07-18 11:42     来源/作者:lcx

核心代码

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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

这篇文章就介绍到这,希望大家以后多多支持服务器之家。

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意 2019-07-07
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分 2019-06-21
返回顶部