WinSCP典型批处理脚本

使用WinSCP有一个技巧是,可以把FTP动作存为一个脚本,日后如果需要重复这个FTP操作,就只需要运行脚本就可以。 如果我们可以自己写脚本,那就很方便了。 例如,我要把本地文件夹 c:\files\abcd 文件夹上传到两个服务器, 服务器1,firstserver.com目标为 /docker/file/abcd/, 服务器2,secondserver.com目标为 /www/file/abcd/, 并且 只上传新的修改过的,文件一致就跳过(-neweronly), 不上传隐藏文件(ExcludeHiddenFiles=1), 不上传.git .gitattributes等git配置文件(-filemask=""| .gitattributes; .git/""), 那么脚本就可以这么写: @echo off “C:\Program Files (x86)\WinSCP\WinSCP.com” ^ /log=“D:\WinSCP.log” /ini=nul ^ /command ^ “open ftp://user1:[email protected]/ -rawsettings Utf=1 ProxyPort=0” ^ “lcd c:\files” ^ “cd /docker/file/” ^ “put -filemask=”"| .gitattributes; .git/"" -neweronly -rawtransfersettings[1] ExcludeHiddenFiles=1 abcd" ^ “open ftp://user2:[email protected] -rawsettings Utf=1 ProxyPort=0” ^ “lcd c:\files” ^ “cd /www/file/” ^ “put -filemask=”"| .gitattributes; .git/"" -neweronly -rawtransfersettings[1] ExcludeHiddenFiles=1 abcd" ^ “exit” ...

2023-07-30 · 1 min · Duke Yin