使用批处理文件和WinSCP将文件从FTP服务器下载到文件服务器(共享文件夹) [英] Using batch file and WinSCP to download files from the FTP server to file server (shared folder)
问题描述
我使用下面的代码将文件从我的FTP服务器传输到我的本地机器上,它工作正常。
C:\ Program Files(x86)\WinSCP\WinSCP.com/ command ^
open ftp:// rnandipati:J13@Files8.cyberlynk.net/kgptel/^
lcdC:\\rnandipati\KGP\File History^
get * .xls> 1D^
rm * .xls< 1D^
exit
现在,我使用此路径访问我的服务器
\\fs01\\ Reporting \KGP\File History
当我把这个路径代替我的本地目录路径时,它显示系统找不到指定的文件和错误更改目录的错误。
感谢。
UNC路径不能成为工作目录在Windows中。
但是,您可以在 get
命令中将它用作目标路径:
get * .xls> 1D\\fs01\Reporting\KGP\File History\
批处理文件的完整命令为:
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
(我并不理解 get * .xls> 1D
和 rm * .xls <1D
) $ b
有关类似问题,请参阅从FTP服务器获取文件并将其复制到UNC目录如果您需要对文件服务器进行身份验证,请参阅:
$ b
$ b
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.
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?
这篇关于使用批处理文件和WinSCP将文件从FTP服务器下载到文件服务器(共享文件夹)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!