国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

一個擴展時間段的dir命令的vbs腳本

2020-06-26 18:12:01
字體:
來源:轉載
供稿:網友
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 
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 赤壁市| 舒城县| 辽源市| 江北区| 榕江县| 永顺县| 闽清县| 右玉县| 溆浦县| 玛纳斯县| 南部县| 泊头市| 北碚区| 日照市| 南投市| 抚顺市| 赤城县| 新宾| 英山县| 青岛市| 阜阳市| 保亭| 望谟县| 三河市| 云林县| 开鲁县| 宁强县| 怀仁县| 普洱| 巴里| 富顺县| 仙居县| 南召县| 渑池县| 宣城市| 承德市| 青田县| 石首市| 和政县| 赣州市| 织金县|