问题
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