The largest file in the most recent folder:
![]()
Sub largest_file_in_most_recent_folder() c00 = "E:\OF\" c01 = "E:\text.txt" For j = 1 To 2 If Dir(c01) <> "" Then Kill c01 Open c01 For Output as #1 Close # Shell "cmd Dir " & c00 & Choose(j, "*.", "*.??*") & Choose(j, " /b /o-d > ", " /b /o-s > ") & c01 Do DoEvents Loop Until FileLen(c01) > 0 Open c01 For Input As #1 c00 = c00 & Split(input(LOF(1), #1), vbCrLf)(0) & IIf(j = 1, "\", "") Close #1 Next End Sub
Bookmarks