title: How to check if files in a path are of a particular type (in VB script)?
body: <p>I currently have a batch file which calls a vbscript that actually does the work I need (coz I have no experience with doing batch files). Take note, I just got this code off the internet. </p>
  
  <p><strong>What I want to happen in the VB Script</strong>
  Basically, I will provide a path and the code will check if specific files (either CSV or XML) exist. If these files exist, they will be placed in a zip file.</p>
  
  <p><strong>What is happening in the VB Script</strong> Currently, the vbscript will get all the files in the path provided and all of it will be zipped into one file. I want to change this code so that it will only zip files that are CSV for example. </p>
  
  <hr>
  
  <p>Batch code</p>
  
  <pre><code>CScript czip.vbs "C:\Users\donatoma\Documents\Folder1\" "C:\Users\donatoma\Documents\Folder2\CSV files.zip"
  </code></pre>
  
  <hr>
  
  <p>VB Script</p>
  
  <pre><code>'Get command-line arguments.
  Set objArgs = WScript.Arguments
  InputFolder = objArgs(0)
  ZipFile = objArgs(1)
  
  'Create empty ZIP file.
  CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" &amp; Chr(5) &amp; Chr(6) &amp; String(18, vbNullChar)
  
  Set objShell = CreateObject("Shell.Application")
  
  Set source = objShell.NameSpace(InputFolder).Items &lt;-- GET CSV FILES, ADD TO AN ARRAY
  
  objShell.NameSpace(ZipFile).CopyHere(source)
  
  'Required!
  wScript.Sleep 2000
  </code></pre>
  
  <p><strong>UPDATED CODE</strong></p>
  
  <pre><code>Set objArgs = WScript.Arguments
  InputFolder = objArgs(0)
  ZipFile = objArgs(1)
  
  'Create empty ZIP file.
  CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" &amp; Chr(5) &amp; Chr(6) &amp; String(18, vbNullChar)
  
  Set objShell = CreateObject("Shell.Application")
  
  Set source = objShell.NameSpace(InputFolder).Items
  
  For i = 0 to source.Count - 1
      If InStr(".csv", Right(source.item(i).Name, 4)) &gt; 0 Then
          objshell.Namespace(ZipFile).CopyHere (source.item(i))
      End If
  Next
  </code></pre>