title: Get the last modified file from a folder with specific extension in vbs
body: <p>i have the following piece of code all I need is to find the file with extension PNG and most recent last modified date, I am able to find the last modified date, but if I place check of extension over file it gives error of [Object needed 'recentFile' at line [some number]]</p>
  
  <p><strong>SCRIPT</strong></p>
  
  <pre><code>For Each objFile in colFiles
      ' Finds the latest modified file in folder
      if (recentFile is nothing) then
          Set recentFile = objFile
          elseif (objFile.DateLastModified &gt; recentFile.DateLastModified) then
              Set recentFile = objFile
      end if
  Next
  </code></pre>
  
  <p>I know I can check extension later on but the issue is that what if there is a file which is latest and is not PNG? while there are files with PNG extension but not latest as compare to other files, so I just need to find PNG with last modified date to latest for only PNG files, please help how can I implement it?</p>