我创建了一个批处理文件,用于将文件从UNIX (Solaris)服务器移动到Windows XP计算机。在此过程中,它将删除UNIX服务器上的文件。
我想做的是,一旦文件被传输到"本地";我想让它将一些文件(RT*.dcm
)复制到另一个本地(映射的网络驱动器)文件夹。
我想将(仅)放在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
命令(或者xcopy
,如果您喜欢的话)。
如果您的WinSCP脚本名为script.txt
,请将其包装为Windows批处理文件,如:
@echo off
winscp.com /script=script.txt /log=winscp.log
copy C:DICOMRT*.dcm L:dicomrt
查看类似的示例,在上传成功后将本地文件移动到不同的位置。
或者您可以将两个文件合并为一个文件,如:
@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:DICOMRT*.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
.