一個(gè)擴(kuò)展時(shí)間段的dir命令的vbs腳本
核心代碼
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 & "個(gè)." & vbCrLf & "共搜索目錄:" & DirTotal & "個(gè)." &vbcrlf&"文件總數(shù)大小"&FormatNumber(FileTotalsize/1024,0)&"kB"& vbCrLf & "用時(shí):" & 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
這篇文章就介紹到這,希望大家以后多多支持我們。
上一篇:用vbs實(shí)現(xiàn)向任何電子郵件發(fā)送郵件
欄 目:vb
下一篇:用vbs實(shí)現(xiàn)的exe2swf工具腳本代碼
本文標(biāo)題:一個(gè)擴(kuò)展時(shí)間段的dir命令的vbs腳本
本文地址:http://www.jygsgssxh.com/a1/vb/7741.html
您可能感興趣的文章
- 01-10什么是一個(gè)高效的軟件
- 01-10VBS教程:運(yùn)算符-賦值運(yùn)算符 (=)
- 01-10VBS教程:函數(shù)-Year 函數(shù)
- 01-10VBS教程:函數(shù)-Eval 函數(shù)
- 01-10VBS教程:函數(shù)-Join 函數(shù)
- 01-10[vbs]每一行的最后一個(gè)字符轉(zhuǎn)換成
- 01-10一個(gè)可以更換windows xp or 2003的序列號(hào)的vbs腳本
- 01-10一個(gè)可以刪除指定天數(shù)文件的vbs腳本
- 01-10使用ADSI、ASP和一對(duì)魔術(shù)戲法自動(dòng)地創(chuàng)立一個(gè)虛擬目錄的方法
- 01-10按鍵精靈 腳本-學(xué)習(xí)VBS的一個(gè)不錯(cuò)的教程


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
- 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
- 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
- 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
- 5c語(yǔ)言計(jì)算三角形面積代碼
- 6什么是 WSH(腳本宿主)的詳細(xì)解釋
- 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
- 8正則表達(dá)式匹配各種特殊字符
- 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
- 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
本欄相關(guān)
- 01-10下載文件到本地運(yùn)行的vbs
- 01-10飄葉千夫指源代碼,又稱(chēng)qq刷屏器
- 01-10SendKeys參考文檔
- 01-10什么是一個(gè)高效的軟件
- 01-10VBS中的正則表達(dá)式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本應(yīng)用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一課深入VBScript
- 01-10VBScript語(yǔ)法速查及實(shí)例說(shuō)明
隨機(jī)閱讀
- 01-10C#中split用法實(shí)例總結(jié)
- 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
- 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
- 01-10delphi制作wav文件的方法
- 01-11Mac OSX 打開(kāi)原生自帶讀寫(xiě)NTFS功能(圖文
- 04-02jquery與jsp,用jquery
- 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
- 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
- 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
- 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什


