moorejc
asked on
Need a VBScript to compare file path and extract the folder name with greastest number
I have a script that extracts the subfolder names. The root folder has a numeral name, which equates to the latest folder created and newest contents. I will need to compare all the folders and copy the "one" folder name with the highest number. I have the path of all the folder names listed after my script. I will need a script to compare the last 4 digits at the end of these paths and determine the one with the highest number. In my case, 4799 would be the highest number or most current folder.
OUTPUT
\\server\install\System\Bu ilds\4684
\\server\install\System\Bu ilds\4694
\\server\install\System\Bu ilds\4797
\\server\install\System\Bu ilds\4799
OUTPUT
\\server\install\System\Bu
\\server\install\System\Bu
\\server\install\System\Bu
\\server\install\System\Bu
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder("\\server\install\System\Builds\")
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Wscript.Echo Subfolder.Path
'ShowSubFolders Subfolder
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you sift-3. -- worked out great. Why did you have "\" in the Wscript echo line?
The value of the intHighest variable is just the folder name. Echoing the full path requires concatenating the strFolder variable, a backslash, and then intHighest.
will give you the last 4 characters to do comparison.