How to move files in a batch to different folders based on result of an upload with WinSCP

我是研究僧i 提交于 2021-02-19 07:32:11

问题


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.

HERE IS 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

Thanks in advance


回答1:


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.

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)

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



来源:https://stackoverflow.com/questions/60423080/how-to-move-files-in-a-batch-to-different-folders-based-on-result-of-an-upload-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!