如何根据使用 WinSCP 上传的结果将文件批量移动到不同的文件夹
How to move files in a batch to different folders based on result of an upload with WinSCP
我是 WinSCP 的新手。我正在尝试为批处理 IM 运行 设置错误级别。如果 Errorlevel= 0 PRINT SUCCESS 并将错误级别为 0 的那些文件传输到文件夹调用成功。
如果错误不等于 0,则将错误级别的文件移动到不同的文件夹调用错误。任何建议。
这里是 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 log。但是很难(如果可能的话)在批处理文件中 parse/process 那些 XML 文件。
你最好使用更强大的脚本语言,比如 PowerShell。
例如参见 [=11=].
(这里还有很多其他类似的问题)
还有关于此主题的 WinSCP 文章:
Moving local files to different location after successful upload
我是 WinSCP 的新手。我正在尝试为批处理 IM 运行 设置错误级别。如果 Errorlevel= 0 PRINT SUCCESS 并将错误级别为 0 的那些文件传输到文件夹调用成功。 如果错误不等于 0,则将错误级别的文件移动到不同的文件夹调用错误。任何建议。
这里是 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 log。但是很难(如果可能的话)在批处理文件中 parse/process 那些 XML 文件。
你最好使用更强大的脚本语言,比如 PowerShell。
例如参见 [=11=].
(这里还有很多其他类似的问题)
还有关于此主题的 WinSCP 文章:
Moving local files to different location after successful upload