批处理文件 WinSCP。复制到两个本地文件夹

Batch File WinSCP. Copy to two local folders

我创建了一个批处理文件,用于将文件从 UNIX (Solaris) 服务器移动到 Windows XP 计算机。在此过程中,它会从 UNIX 服务器中删除文件。

我想做的是,一旦文件被传输到 "local" 计算机(安装了 WinSCP 程序的地方),我希望它将一些文件复制到另一台本地(映射网络驱动器)文件夹。

我想(仅)将 C:\DICOM 文件夹中的文件复制到 L:\dicomrt 文件夹中。

这是我在初始部分使用的内容:

# Created by Daniel E. Cronk to transfer images from the Pinnacle RT station to the LinAc computer.

# Comment out the next two lines to test
option batch on
option confirm off

# Connect - format: user:password@host
open ftp://username:password@hostname

# Change remote directory
cd /files/network/DICOM

# Change Local Directory
lcd C:\DICOM

# Force binary mode transfer
option transfer binary

# Download backup file to the local directory
get -delete RT*.dcm
get -delete CT*.dcm
get -delete MR*.dcm

# Disconnect
close

# Exit WinSCP
exit

在 WinSCP 中没有本地到本地复制文件的命令,因为不需要它,因为您可以使用 Windows copy command(或 xcopy,如果您愿意的话) .

如果您的 WinSCP 脚本名为 script.txt,请将其包装到 Windows 批处理文件中,例如:

@echo off

winscp.com /script=script.txt /log=winscp.log

copy C:\DICOM\RT*.dcm L:\dicomrt\

查看类似示例 Moving local files to different location after successful upload


或者您可以将两个文件合二为一,例如:

@echo off

winscp.com /log=winscp.log /command ^
    "open ftp://username:password@hostname" ^
    "option batch on" ^
    "cd /files/network/DICOM" ^
    "lcd C:\DICOM" ^
    "get -delete RT*.dcm" ^
    "get -delete CT*.dcm" ^
    "get -delete MR*.dcm" ^
    "close" ^
    "exit"

copy C:\DICOM\RT*.dcm L:\dicomrt\

请注意,在最新版本的 WinSCP 中不需要 option confirm off 命令。 WinSCP 现在也默认为 option batch abort(可能比你的 option batch on 更合适)。

https://winscp.net/eng/docs/scripting#using_scripting

WinSCP 也默认为二进制模式,所以 option transfer binary 也不是必需的。无论如何,这是一种已弃用的语法,正确的语法是 get -transfer=binary -delete RT*.dcm.