title: Recursive folder synchronization using VBScript (Mirror Folders)
body: <p>I've never really written in vbs (once wrote a script that would welcome me on boot) but I'm after a script to essentially perform :</p>
  
  <pre><code>robocopy "folder1" "folder2" /MIR
  </code></pre>
  
  <p>At the moment what I've got is a copied script from here <a href="http://www.808.dk/?code-foldersync" rel="nofollow">VBS Mirror</a>, Using the top script :</p>
  
  <blockquote>
    <p>This code synchronizes the contents (files and subfolders) of two
    folders. Each folder is traversed recursively and any missing
    subfolders and files are copied both ways. If corresponding folders
    contain files with matching file names but with different time stamps,
    the file with the newest time stamp will overwrite the older.</p>
  </blockquote>
  
  <p><strong><em>SyncFolders.vbs</em></strong></p>
  
  <pre><code>Option Explicit
  ForceScriptEngine("cscript")
  
  Dim wshArgs
  Set wshArgs = Wscript.Arguments
  If WshArgs.Count = 2 Then
    Call SyncFolders(WshArgs.Item(0), WshArgs.Item(1))
    ' Also run once in reverse to catch mismatching subfolder count:
    Call SyncFolders(WshArgs.Item(1), WshArgs.Item(0))
  Else
    Wscript.Echo("Wrong number of arguments. Syntax: SyncFolders Folder1 Folder2")
    Wscript.Sleep(3000) ' To allow Function syntax popup message to be seen.
  End If
  
  Sub SyncFolders(strFolder1, strFolder2)
    Dim objFileSys
    Dim objFolder1
    Dim objFolder2
    Dim objFile1
    Dim objFile2
    Dim objSubFolder
    Dim arrFolders
    Dim i
    Set objFileSys = CreateObject("Scripting.FileSystemObject")
    arrFolders = Array(strFolder1, strFolder2)
    For i = 0 To 1 ' Make sure that missing folders are created first:
      If objFileSys.FolderExists(arrFolders(i)) = False Then
        wscript.echo("Creating folder " &amp; arrFolders(i))
        objFileSys.CreateFolder(arrFolders(i))
      End If
    Next
    Set objFolder1 = objFileSys.GetFolder(strFolder1)
    Set objFolder2 = objFileSys.GetFolder(strFolder2)
    For i = 0 To 1
      If i = 1 Then ' Reverse direction of file compare in second run
        Set objFolder1 = objFileSys.GetFolder(strFolder2)
        Set objFolder2 = objFileSys.GetFolder(strFolder1)
      End If
      For Each objFile1 in objFolder1.files
        If Not objFileSys.FileExists(objFolder2 &amp; "\" &amp; objFile1.name) Then
          Wscript.Echo("Copying " &amp; objFolder1 &amp; "\" &amp; objFile1.name &amp; _
            " to " &amp; objFolder2 &amp; "\" &amp; objFile1.name)
          objFileSys.CopyFile objFolder1 &amp; "\" &amp; objFile1.name, _
            objFolder2 &amp; "\" &amp; objFile1.name
        Else
          Set objFile2 = objFileSys.GetFile(objFolder2 &amp; "\" &amp; objFile1.name)
          If objFile1.DateLastModified &gt; objFile2.DateLastModified Then
            Wscript.Echo("Overwriting " &amp; objFolder2 &amp; "\" &amp; objFile1.name &amp; _
              " with " &amp; objFolder1 &amp; "\" &amp; objFile1.name)
            objFileSys.CopyFile objFolder1 &amp; "\" &amp; objFile1.name, _
              objFolder2 &amp; "\" &amp; objFile1.name    
          End If
        End If
      Next
    Next
    For Each objSubFolder in objFolder1.subFolders
      Call SyncFolders(strFolder1 &amp; "\" &amp; objSubFolder.name, strFolder2 &amp; _
        "\" &amp; objSubFolder.name)
    Next
    Set objFileSys = Nothing
  End Sub
  
  Sub ForceScriptEngine(strScriptEng)
    ' Forces this script to be run under the desired scripting host.
    ' Valid arguments are "wscript" or "cscript".
    ' The command line arguments are passed on to the new call.
    Dim arrArgs
    Dim strArgs
    For Each arrArgs In WScript.Arguments
      strArgs = strArgs &amp; " " &amp; Chr(34) &amp; arrArgs &amp; Chr(34)
    Next
    If Lcase(Right(Wscript.FullName, 12)) = "\wscript.exe" Then
      If Instr(1, Wscript.FullName, strScriptEng, 1) = 0 Then
        CreateObject("Wscript.Shell").Run "cscript.exe //Nologo " &amp; _
          Chr(34) &amp; Wscript.ScriptFullName &amp; Chr(34) &amp; strArgs
        Wscript.Quit
      End If
    Else
      If Instr(1, Wscript.FullName, strScriptEng, 1) = 0 Then
        CreateObject("Wscript.Shell").Run "wscript.exe " &amp; Chr(34) &amp; _
          Wscript.ScriptFullName &amp; Chr(34) &amp; strArgs
        Wscript.Quit
      End If
    End If
  End Sub
  </code></pre>
  
  <p>I changed the :</p>
  
  <pre><code>Sub SyncFolders(strFolder1, strFolder2)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>Sub SyncFolders(strC:\Users\Zac\Desktop\Folder, strW:\Folder)
  </code></pre>
  
  <p>and get the error "Expected ')'</p>
  
  <p>I'm sure it's something very obvious, but could someone please tell me what I need to change in that script to make my folders mirror each other?</p>