WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Operations

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Oldest or Newest File

 Keywords: Old New Oldest Newest Latest Created Modified File Folder Directory FileInfoToArray ArraySort

Question:

Hi guys I need to figure out how to pick out the latest file that was created or thrown into a folder, and then do something with that file. Is there a function for this? Thank you much!

Answer:

Here is a couple of examples that show how to get the newest file in a folder.
arrFI = FileInfoToArray ("*.*")
ArraySort (arrFI, @ASCENDING, 2, 1)
strFileLatest = arrFI [arrFI[0, 0], 0]
Or
arrFI = FileInfoToArray ("*.*")
ArraySort (arrFI, @DESCENDING, 2, 1)
strFileLatest = arrFI [1, 0]

Article ID:   W17874
Filename:   Get Oldest or Newest File.txt
File Created: 2011:06:08:09:21:06
Last Updated: 2011:06:08:09:21:06