一個擴(kuò)展時間段的dir命令的vbs腳本
更新時間:2008年05月20日 22:12:56 作者:lcx
CMD下的dir好像沒法列出從某段時間到某段時間的文件,所以寫了這個小東東,方便根據(jù)我們的要求顯示數(shù)據(jù)
核心代碼
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&"文件總數(shù)大小"&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
這篇文章就介紹到這,希望大家以后多多支持腳本之家。
相關(guān)文章
Springboot Thymeleaf數(shù)據(jù)迭代實現(xiàn)過程
這篇文章主要介紹了Springboot Thymeleaf數(shù)據(jù)迭代實現(xiàn)過程,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2007-12-12用vbs返回 Internet Explorer 的下載控件和 Applet 的列表
用vbs返回 Internet Explorer 的下載控件和 Applet 的列表...2007-04-04用VBS實現(xiàn)一個小鍵盤動作CTRL+V粘貼操作與思路分析
我想實現(xiàn)當(dāng)有跳出窗口"請輸入"時的1.8秒后就發(fā)送一次 CTRL + V,把本來已經(jīng)復(fù)制到剪切版中的文字自動粘貼過去呢2009-12-12xp、2003開3389+非net創(chuàng)建管理用戶+Shift后門+自刪除腳本vbs
喜歡VBS腳本的朋友可以下載使用。此腳本免殺,可以用于WebShell提供時使用,適用于2003系統(tǒng)和XP系統(tǒng)。2008-06-06利用VBS實現(xiàn)顯示系統(tǒng)服務(wù)列表
顯示服務(wù)列表的方法有很多,在接下來的文章中為大家介紹下利用VBS是如何實現(xiàn)的,感興趣的朋友不要錯過2013-11-11