指定したフォルダ内で一番新しいファイル、一番古いファイルを調べるサンプルコードです。
指定したフォルダで一番最初に更新されたファイル(要するに一番古いファイル)を調べる
サンプル:
Set objFSo = CreateObject("Scripting.FileSystemObject")  
Set objFolder = objFSO.GetFolder("C:\temp")  
  
Set cFiles = objFolder.Files  
  
oldestDate = Now  
oldestFile = ""  
   
For Each objFile in cFiles  
    If objFile.datelastmodified < oldestDate Then  
        oldestDate = objFile.datelastmodified
        oldestFile = objFile.Path 
       
    End If  
Next  
wscript.echo oldestDate
wscript.echo oldestFile
一番最後に更新されたファイル(要するに一番新しいファイル)を表示します。
サンプル:
Set objFSo = CreateObject("Scripting.FileSystemObject")  
Set objFolder = objFSO.GetFolder("C:\temp")  
  
Set cFiles = objFolder.Files  
  
newestDate = cdate("1975/01/01 00:00:00")
newestFile = ""  
   
For Each objFile in cFiles  
    If objFile.datelastmodified > newestDate Then  
        newestDate = objFile.datelastmodified
        newestFile = objFile.Path 
    End If  
Next  
wscript.echo newestDate
wscript.echo newestFile