title: SFTP transfer file and move file to folder
body: <p>This is my first post so please excuse my ignorance. I am using a vbscript to zip all .csv type files in a particular folder. After some google searches, I have found a workable <a href="http://www.experts-exchange.com/Programming/Languages/Scripting/Q_24083472.html" rel="nofollow noreferrer">vbscript</a> to do this and have enabled a scheduled task to automate this.</p>
  
  <p>What I need to do next is to transfer the zip file via sftp and then "move" that zip file into another folder. I believe the former can be achieved using pscp.exe via command line but can someone show me how to do the latter?</p>
  
  <p>Basically the zipping will be done twice a day and so it will have a timestamp similar to <code>yyyymmdd0900.zip</code> (for 9am schedule) and <code>yyyymmdd1800.zip</code> (for 6pm schedule). After the transfer, I want to move (not copy) the zip file generated into another folder.</p>
  
  <p>Any pointers would be greatly appreciated. Thank you all in advance.</p>
  
  <p>EDIT: Here is some code I slapped together based on some Google searches. It does what I want it to do. Please excuse the "pasting" as i couldn't figure out how to format it properly. Currently, it runs the bat file after copying but I just noticed that i need to send (using PuTTY Secure Copy) the "latest" zip file before moving it to the "completed" folder. Can someone please show me how to do this?</p>
  
  <blockquote>
    <p>Zipping the file and rename the zip file</p>
  </blockquote>
  
  <p>My Code : </p>
  
  <pre><code>On Error Resume Next
  strFilepath = "c:\files"
  strDestination = "c:\files\completed\"
  strExtension = "csv"
  
  strYear = Year(Now)
  
  strMonth = Right("0" &amp; Month(Now), 2)
  
  strDay = Right("0" &amp; Day(Now), 2)
  
  strHour = Right ("0" &amp; Hour(Now), 2)
  
  strMinute = Right ("0" &amp; Minute (Now), 2)
  
  
  strZip = strFilepath &amp; "\" &amp; strYear &amp; strMonth &amp; strDay &amp; strHour &amp; strMinute &amp; ".zip"
  
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  
  Set objFolder = objFSO.GetFolder(strFilepath)
  
  For Each objFile in objFolder.Files
  
      strFileExt = objFSO.GetExtensionName(objFile.Path)
          If LCase(strFileExt) = LCase(strExtension) Then
          ZipFile objFile.Path, strZip
      End If
  Next
  
  Sub ZipFile(strFileToZip, strArchive)
  
  Set objFSO = CreateObject("Scripting.FileSystemObject")  
  
      If Not objFSO.FileExists(strArchive) Then
          Set objTxt = objFSO.CreateTextFile(strArchive)
          objTxt.Write "PK" &amp; Chr(5) &amp; Chr(6) &amp; String(18, Chr(0))
          objTxt.Close
      End If
  
      Set objApp = CreateObject( "Shell.Application" )
  
      intCount = objApp.NameSpace(strArchive).Items.Count + 1
  
      objApp.NameSpace(strArchive).CopyHere strFileToZip
  
      Do
          WScript.Sleep 200
          set objNameSpace = objApp.NameSpace(strArchive)
  
          If Not objNameSpace is nothing Then        
              If objNameSpace.Items.Count = intCount Then
                  Exit Do
              End If
          End If
      Loop
  End Sub
  
  &gt;Move file to a different folder and then run a bat file to secury copy file to a FTP location
  
  'Vars
  
  Dim objFSO, objFileCopy, objFileDelete, dot, files, file
  
  Dim strDestination, folder, subfolder, fileCount, strFilePath
  
  'Strings
  
  strDestination = "C:\Files\Completed\"
  
  strFilePath = "C:\Files"
  
      set objFSO = CreateObject("Scripting.fileSystemObject") 
  
      set folder = objFSO.getFolder(strFilePath) 
  
  For Each file In folder.files
  
  Set objFileCopy = objFSO.GetFile(file)
  
         If objFSO.GetExtensionName(file) = "zip" Then                
          objFSO.MoveFile objFileCopy.Path, strDestination
         End If
  
  
  Next
  
  Dim shell
  
  Set shell=createobject("wscript.shell")
  
  Shell.run "C:\testsend.bat"
  
  Set shell=nothing
  </code></pre>