开发者

How to find last modified subfolder?

开发者 https://www.devze.com 2023-01-23 07:40 出处:网络
I have a log folder that contains subfolders with log files of a build server. Each time a build is triggered, a new s开发者_运维技巧ubfolder is created with log files.

I have a log folder that contains subfolders with log files of a build server. Each time a build is triggered, a new s开发者_运维技巧ubfolder is created with log files. I want to find the path to the last created subfolder within the main build folder.

Can anyone point me in the right direction?


You can use the FileSystemObject.

Set fs = CreateObject("Scripting.FileSystemObject")
Set MainFolder = fs.GetFolder("C:\Docs")
For Each fldr In MainFolder.SubFolders
    ''As per comment
    If fldr.DateLastModified > LastDate Or IsEmpty(LastDate) Then
        LastFolder = fldr.Name
        LastDate = fldr.DateLastModified
    End If
Next

MsgBox LastFolder
0

精彩评论

暂无评论...
验证码 换一张
取 消