Trying to Get MV to Pull File from SFTP and Move to Remote Share

Advertisement

res74
Joined:
Posts:
2

Trying to Get MV to Pull File from SFTP and Move to Remote Share

Hello!

I need to create a script to automatically move files from an SFTP site to a remote server share
SFTP --> \\remoteservername\directory

I've tried using the get * and then rm * but because there is a gap in time between those 2 commands, it's deleting files that are not processed already. Basically we connect to an SFTP server and just get the files on there and remove them once we have them. I have this in batch file currently and looking for some help. What I have so far:

@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\scripts\FTPScripts\microProd.log" /logsize=10*10M /ini=nul ^
  /command ^
    "open sftp://thesite""" ^
    "lcd \\perseus\micro\active" ^
    "cd \" ^
    "get *" ^
    "rm *" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

Any help is greatly appreciated!

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum