How to find last modified subfolder?
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
精彩评论