|
Answer» Hello, firstly THANKS for reading this post and appologies if i am REPEATING past requests.
I have a set of directories with the following format - yyyymmdd (ie 20070813 etc) and want to be able to find the directory that has the greatest number. I dont want to use the last modified date as it could be possible that a lower number (earlier date) was RECENTLY modified. I have tried using for loops but got stuck. any help would be greatly appreciated.
Thanks
Timi may get your requirement wrong, however, just by comparing numbers, Code: [Select]Option Explicit Dim temp,objFSO,objFolder,Folder,folders Set objFSO=CreateObject("Scripting.FileSystemObject") Folder="c:\dir_that_contains_those_folders" temp=0 Set objFolder=objFSO.GetFolder(Folder) For Each folders In objFolder.SubFolders If folders.Name > temp Then temp=folders.Name End If Next WScript.Echo "Biggest directory is",temp save as myscript.vbs and run from command line : cscript /nologo myscript.vbsAssuming that this directory hold only the directories in the format you quoted, this will return the newest (by date in the name) directory in %NewestDir%
Dir dir /b /ad /o-n>$temp$ Set/P NewestDir=<$temp$ Del $temp$
GrahamThanks for the help from the both of you. I used Grahams SUGGESTION and it did just what i WANTED it to. I did not think about the vbsript idea... so that will be useful for future.
Tim
|