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

问题描述 投票:1回答:1

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

我想做的是,一旦文件被转移到“本地”计算机(安装了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
batch-file winscp
1个回答
1
投票

在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

© www.soinside.com 2019 - 2024. All rights reserved.