Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
To find the latest file
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
How can we write a script to find a latest file in a folder

Thanks
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
Based on modified date of files we can get, means the file one having latest modified date is the latest file.

Code:
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Folder = FSO.GetFolder("D:\test")
LatestModifiedFileDate = #1/1/0001#
For Each File In Folder.Files
    If  File.DateLastModified > LatestModifiedFileDate Then
        LatestModilfiedFile= File.Name
        LatestModifiedFileDate = File.DateLastModified
    End If
Next
msgbox (LatestModilfiedFile)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to find a file after downloading UFT_Newbie 1 2,997 09-18-2014, 08:43 PM
Last Post: UFT_Newbie
  how to find Excel file exist or not in vbscript code sree.85 3 11,331 08-22-2013, 11:42 AM
Last Post: akhandesh

Forum Jump:


Users browsing this thread: 1 Guest(s)