title: vbs copy and rename file
body: <p>I'm trying to create a sub in VBScript to move an copy a file. I've tried a few different approaches that I found on here, as well as some other sites. I have the following working.</p>
  <pre><code>dim SEVO_XML_PATH 'File path to Sevo xml file
  dim SEVO_BACKUP 'File path for sevo's backup location
  SEVO_XML_PATH=&quot;xml\Database.xml&quot;
  SEVO_BACKUP=&quot;backup\&quot;   
  
  sub BackupSevo()
      If FSO.fileExists(SEVO_XML_PATH)=true then
          FSO.copyFile SEVO_XML_PATH, SEVO_BACKUP
      else
          msgbox(&quot;Sevo XML not found.&quot; &amp; vbnewline &amp; &quot;Please contact Engineering.&quot;)
      end if
  end sub
  </code></pre>
  <p>However I want to append the date to the end of the file name. When I add the name of the file being pasted like <a href="https://stackoverflow.com/questions/12393389/copy-and-rename-file-vbscript">so</a>...</p>
  <pre><code>backupName = &quot;Database_&quot; &amp; date &amp; &quot;.xml&quot;
  FSO.copyFile SEVO_XML_PATH, SEVO_BACKUP &amp; backupName
  </code></pre>
  <p>This gives me a &quot;Path not Found&quot; error. I've tried copying the  the file then using moveFile to rename it, but I got the same error.</p>
  <pre><code>FSO.copyFile SEVO_XML_PATH, SEVO_BACKUP
  dim backupName
  backupName = &quot;Database_&quot; &amp; date &amp; &quot;.xml&quot;
  FSO.moveFile SEVO_BACKUP &amp; &quot;Database.xml&quot;, SEVO_BACKUP &amp; backupName
  </code></pre>
  <p>I tried a method that I found <a href="https://stackoverflow.com/questions/19683373/copy-and-rename-oldest-file-using-vbs">here</a> to create an object to hold the file, then using the name property to change the name.</p>
  <pre><code>set sevoXML=FSO.getFile(SEVO_XML_PATH)
  sevoXML.copy SEVO_BACKUP
  set sevoXMLBackup=FSO.getFile(SEVO_BACKUP &amp; &quot;Database.xml&quot;)
  sevoBackup.name=backupName
  </code></pre>
  <p>But I get the error &quot;Invalid procedure call or argument&quot; on the last line.</p>
  <p>Any ideas, on either fixing one of these methods, or using a different one?
  Thanks</p>