|
-
Dec 3rd, 2007, 07:45 AM
#1
Thread Starter
Addicted Member
Sorting Folder Contents
Hi All,
I have a drive (lets call it "H") that will have a dynamic list of folders within it. The folders will work off of a date naming convention, example 20071105.
I need to be able to sort the contents of the "H" drive and return the oldest folder using a .vbs script.
For Example:
"H" Drive contents:
20071119
20071105
20070509
20071126
20071203
20070912
20071112
I would like to return the oldest folder name. In this case, 20070509.
Any help would greatly be appreciated. Thank you!
-
Dec 6th, 2007, 05:05 PM
#2
Lively Member
Re: Sorting Folder Contents
Code:
Function getLowestMatch(arrIn())
Dim i, j, strBuff
strBuff = arrIn(LBound(arrIn))
For i = LBound(arrIn) + 1 To UBound(arrIn)
If strBuff > arrIn(i) Then
strBuff = arrIn(i)
End If
Next
getLowestMatch = strBuff
End Function
Dim oFS, oFolder, oFCol
Dim arrFolders(), i
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFCol = oFS.GetFolder("H:\").SubFolders
ReDim arrFolders(0)
i = 0
For Each oFolder In oFCol
arrFolders(UBound(arrFolders)) = oFolder.Name
ReDim Preserve arrFolders(UBound(arrFolders) + 1)
Next
ReDim Preserve arrFolders(UBound(arrFolders) - 1)
MsgBox getLowestMatch(arrFolders)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|