代码之家  ›  专栏  ›  技术社区  ›  Salek

从子文件夹中查找最后一个名为month的文件夹

  •  1
  • Salek  · 技术社区  · 7 年前

    “somepath\YYYY\MMMYYYY”

    "somepath\2017\MAR2017" . "MMMYYYY" 在“年份”文件夹中。

    我尝试将文件夹名转换为数字:

    Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
    Dim ObjFolder : Set ObjFolder = fso.GetFolder("somepath\2017\")
    Set fc = ObjFolder.SubFolders 'here I should get all folders with months in their names
    For each f in fc
    a = Month("01-"&left(f.name, 3)&"-"&right(f.name, 4))
    print a
    Next
    

    4.

    2.

    3.

    a = MonthName(maxnumber)&"2017"
    workingfolder = "somepath\2017\"&a&"\"
    

    如何识别最大数量或最大月份?

    1 回复  |  直到 4 年前
        1
  •  1
  •   Salek    7 年前

    Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
    Dim ObjFolder : Set ObjFolder = fso.GetFolder("somepath\2017\")
    Set fc = ObjFolder.SubFolders
        For i=0 to fc.count
            For each f in fc
                a = Month("01-"&left(f.name, 3)&"-"&right(f.name, 4))
                Redim Preserve arr(fc.count)
                arr(i)=a
            Next
        Next
        arrLen = UBound(arr) 'Find the length of array
        For j= 0 to arrLen
         If arr(j) > max Then
            max=arr(j)
         End If
        Next
    Dim OrgFolder : Set OrgFolder = fso.GetFolder(ObjFolder&"\"&MonthName(arr(0), True)&"2017\")