如何基于WinSCP上载的结果将文件批量移动到其他文件夹 [英] How to move files in a batch to different folders based on result of an upload with WinSCP

查看:103
本文介绍了如何基于WinSCP上载的结果将文件批量移动到其他文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是WinSCP的新手.我正在尝试为批处理IM运行设置一个错误级别.如果Errorlevel = 0,则PRINT SUCCESS并将那些错误级别为0的文件传输到文件夹调用成功.如果错误不等于0,则将具有错误级别的文件移动到不同的文件夹调用错误.有任何建议.

I'm new to WinSCP. I'm trying to set an Errorlevel for the batch IM running. If the Errorlevel= 0 PRINT SUCCESS and transfers those files with Errorlevel 0 to folder call success. if the error not equal to 0 moves the file with the error level to different folder call errors. Any suggestions.

这里是MY.bat

WinSCP.exe /console /script="c:\users\PDP\script.txt" /log="c:\users\PDP\lastrun.txt"
if %ERRORLEVEL% equ 0 
echo Success
sendmail.exe -t < success_mail.txt
move OPTTXM* c:\users\PDP\sent  ( the files in the batch start with OPTTXM*)
exit /b 0

 if %ERRORLEVEL% neq 0  goto error

echo Error!
sendmail.exe -t < error_mail.txt
move  ????????????????????????????????? ( how you can get inside each file and check the status
)
exit /b 1

预先感谢

推荐答案

您可以使WinSCP创建 XML日志包含已传输和未传输的文件.但是很难(如果可能的话)解析/处理批处理文件中的这些XML文件.

You can make WinSCP create XML log with files that were and were not transferred. But it would be difficult (if possible at all) to parse/process those XML files in a batch file.

您最好使用功能更强大的脚本语言,例如PowerShell.
例如,请参见使用PowerShell/WinSCP脚本上传文件后移动文件.
(这里还有许多其他类似的问题)

You better use a more powerful scripting language, like PowerShell.
See for example Move files after upload using PowerShell/WinSCP Script.
(there are many other similar questions here)

关于此主题还有WinSCP文章:
成功上传后将本地文件移动到其他位置

There's also WinSCP article on this topic:
Moving local files to different location after successful upload

这篇关于如何基于WinSCP上载的结果将文件批量移动到其他文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆