title: Vbscript copy files based on beginning letters
body: <p>I am trying to get this script to copy all files starting with "XX". Currently it only copies one file.</p>
  
  <pre><code>Dim objFSO, colFiles, objFile, strDestFolder, objNewestFile
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set colFiles = objFSO.GetFolder("C:\source")
  strDestFolder = "C:\destination\"
  
  For Each objFile In colFiles.Files
    If Left(objFile.Name, 2) = "XX" Then
    If objNewestFile = "" Then   
      Set objNewestFile = objFile  
    Else   
        If objNewestFile.DateLastModified &lt; objFile.DateLastModified Then    
          Set objNewestFile = objFile   
        End If  
    End If
  End If
  Next
  
  If Not objNewestFile Is Nothing Then 
  objFSO.CopyFile objNewestFile.Path,strDestFolder,True
  End If
  
  WScript.Echo "Copied."    
  </code></pre>