Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use vbs to implement a dir command for an extended time period

Shulou Source: shulou.com Published: 2022-06-03 06:44:00 11月15日 Update

This article mainly introduces how to use vbs to achieve an extended time period of dir command, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Core code

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 = Timer myFind Path TimeSpend = round (Timer-TimeSpend) 2) txtResult = "search complete!" & vbCrLf & "find files altogether: & FileTotal &" search directories: "& DirTotal &". & vbcrlf& "total file size" & FormatNumber (FileTotalsize/1024,0) & "kB" & vbCrLf & "time:" & TimeSpend & "seconds." 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) 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 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 Thank you for reading this article carefully I hope the article "how to use vbs to achieve a dir command for an extended time period" shared by the editor is helpful to everyone. At the same time, I also hope that you can support it and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles commands time time periods documents search code value interests at the same time size total more friends core directory knowledge editing industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Microsoft MySQL Shulou Information Apple