I need to find the last subfolder that fits a certain pattern under a given folder, and use it for a process.
And if no such subfolder exists then I have to create one.
Let's say the given folder is:
C:\Proc\MainData\
And I need to find the subfolder with the highest value of "i" (under the given folder) based on the following logic:
Please note that I am talking about subfolders that are DIRECTLY (and not recursively) under the given folder.
Reading the list of all subfolders directly under the given folder is not a problem.
I have a procedure that does it very well:
The above Sub works fine and gives me the list of all subfolders directly under the parent folder in the SubFldrs() array.
The challenge is not reading the subfolder names from the disk (The above Sub does that properly).
The challenge is the actual looping and pattern matching.
For example there may be only one subfolder in there named "List_7563"
So, all the numbers 1 to 7562 being missing.
In this case, my program should return "List_7563" as that is the folder name with highest value of i that fits that pattern.
There could be all kinds of unrelated subfolders in there too, that is subfolders whose names do not fit that pattern.
For example there can be a subfolder named "Details", or any other name
What is the best way of doing this?
Any help on this would be appreciated.
Thanks.
And if no such subfolder exists then I have to create one.
Let's say the given folder is:
Quote:
C:\Proc\MainData\
Code:
Dim i As Long
Sub_Fldr_Name = "List_" & Format(i, "000")
Reading the list of all subfolders directly under the given folder is not a problem.
I have a procedure that does it very well:
Code:
Private Sub Get_Subfolders_Under_Folder(ByRef ParentFldr As String, ByRef SubFldrs() As String)
......
End Sub
The challenge is not reading the subfolder names from the disk (The above Sub does that properly).
The challenge is the actual looping and pattern matching.
For example there may be only one subfolder in there named "List_7563"
So, all the numbers 1 to 7562 being missing.
In this case, my program should return "List_7563" as that is the folder name with highest value of i that fits that pattern.
There could be all kinds of unrelated subfolders in there too, that is subfolders whose names do not fit that pattern.
For example there can be a subfolder named "Details", or any other name
What is the best way of doing this?
Any help on this would be appreciated.
Thanks.