Using batch file and WinSCP to download files from the FTP server to file server (shared folder)

若如初见. 提交于 2019-12-08 06:40:23

问题


I am using the following code to transfer files from my FTP server to my local machine which works fine.

"C:\Program Files (x86)\WinSCP\WinSCP.com" /command ^
    "open ftp://rnandipati:J13@Files8.cyberlynk.net/kgptel/" ^
    "lcd ""C:\\rnandipati\KGP\File History""" ^
    "get  *.xls>1D" ^
    "rm *.xls<1D" ^
    "exit"

Now, I access my server using this path

\\fs01\\Reporting\KGP\File History

When I put this path in place of my local directory path, it shows an error that the system could not find the file specified and error changing directory.

Thanks.


回答1:


A UNC path cannot be a working directory in Windows.

But you can use it as a target path in the get command:

get *.xls>1D "\\fs01\Reporting\KGP\File History\"

A full command for a batch file will be:

"C:\Program Files (x86)\WinSCP\WinSCP.com" /command ^
    "open ftp://rnandipati:J13@Files8.cyberlynk.net/kgptel/" ^
    "get *.xls>1D ""\\fs01\Reporting\KGP\File History\""" ^
    "rm *.xls<1D" ^
    "exit"

(not that I understand a logic of the get *.xls>1D and rm *.xls<1D)

For a similar question, see Get file from FTP server and copy it to UNC directory.


If you need to authenticate to the file server, see:

  • Include credentials of shared folder in WinSCP script file
  • How to give credentials in a batch script that copies files to a network location?


来源:https://stackoverflow.com/questions/43642035/using-batch-file-and-winscp-to-download-files-from-the-ftp-server-to-file-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!