无法在远程目录

时间:2017-09-20 22:11:38

标签: batch-file batch-processing winscp

我正在使用此批处理文件将文件从本地目录移动到远程目录。我可以毫无问题地移动文件。远程目录是一个大约需要一个小时来处理文件的接口。我似乎无法在远程目录中读取文件。我希望程序循环直到文件不在文件夹中,而不是处理下一个文件。

SET LOCAL ENABLEEXTENSIONS
SET LOCAL ENABLEDELAYEDEXPANSION

SET Wave=3
SET WaveDesc=Wave%Wave%Documents
SET Ext=1
SET PadExt=001
SET Practice=xxx
:LOOP

SET FileName=%Practice%_NoConvert_%PadExt%.zip

echo FileName %FileName%

SET Desktop=C:\Users\xxxxxxxxx\Desktop
SET Src_Dir=D:\ChartMaxx\Sent_to_ChartMaxx\%WaveDesc%\%Practice%\Zipped_Folders\
SET Dest_Dir=/xxxxx/xxxxx/%WaveDesc%/%Practice%/

chdir /d %Desktop%
IF EXIST WinSCP.log DEL WinSCP.log

chdir /d %Src_Dir%

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Users\tdonahue\Desktop\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://xxxxxxx:xxxxxx.xxxxxxx.org/ -hostkey=""ssh-ed25519 xxx xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" ^
    "lcd %Src_Dir%" ^
    "cd %Dest_Dir%" ^
    "option transfer binary" ^
    "put -resumesupport=on %FileName%" ^
    "close" ^
    "exit"


set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
pause

echo %WINSCP_RESULT%

echo after winscp
pause
:SkipWinscp
@REM Check if file still exists

:FOLDERCHECK
echo Directory  %Dest_Dir% 
pause

chdir /d cd %Dest_Dir%

echo %Dest_Dir%
pause 
SET FileCheck=%Dest_Dir%%FileName%
pause

IF EXIST %FileCheck% GOTO:LOOPAGAIN
IF NOT EXIST %FileCheck% GOTO:ADDCOUNT
:LOOPAGAIN
echo at Loopagain
pause
echo Folder %FileCheck% still exists waiting till it is gone
echo waiting 15 sceonds
timeout /t 15
IF EXIST %FileCheck% GOTO:LOOPAGAIN

pause

:ADDCOUNT
echo at add count
pause
if %Ext% LEQ 9 SET PadExt=00%Ext%
IF %Ext% GEQ 10 if %Ext% LEQ 99 SET PadExt= 0%Ext%
SET /A Ext= %Ext%+1
GOTO:LOOP

:END
pause

0 个答案:

没有答案