vbs script to send files via ftp and check/delete original files

前端 未结 1 843
小鲜肉
小鲜肉 2021-01-06 13:18

I\'m trying to send files over ftp and afterwards check if the process was completed successfully, if it was I would delete the original files and keep only the ones sent in

1条回答
  •  隐瞒了意图╮
    2021-01-06 13:32

    Not sure if this is the best way but you can get a file listing via the FTP command and compare the results to what you're expecting. Here's an example:

    ' Create the FTP command file...
    With CreateObject("Scripting.FileSystemObject").CreateTextFile("c:\ftp.txt", True)
        .WriteLine "USER test"
        .WriteLine "testtest"
        .WriteLine "ls /htdocs/test/"
        .WriteLine "quit"
        .Close
    End With
    
    ' Run the command and capture its output...
    With CreateObject("WScript.Shell")
        .Run "%comspec% /c ftp -n -v -s:c:\ftp.txt ftp.test.com >c:\filelist.txt", 0, True
    End With
    

    This would create the file c:\filelist.txt, which you could then open and check for the existence of the file(s) you've uploaded. Of course, you can add additional args to the ls command to get more detailed info. For example, ls -l would give you the date updated as well as the file size.

    0 讨论(0)
提交回复
热议问题