Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

midnite8

Simple Synchronize Script

I am trying to synchronize files from remote to local and having some issues getting the bat file to work.

I currently have it setup like this:
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Temp\WinSCP Logs\WinSCP.log" /ini=nul ^
  /command ^
    "open sftp://user:password@secureftp.domain.com/ -hostkey=""hostkey""" ^
    "synchronize remote C:\Users\User1\Desktop\SychronizedFolder //servername/Test1" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%


When running this in command line and looking at the log file, I get this:
. 2023-01-05 13:25:58.919 Real path is '/F:/Test1'
. 2023-01-05 13:25:58.919 Startup conversation with host finished.
< 2023-01-05 13:25:58.919 Script: Session started.
< 2023-01-05 13:25:58.919 Script: Active session: [1] user1@secureftp.domain.com
> 2023-01-05 13:25:58.919 Script: synchronize remote C:\Users\User1\Desktop\SychronizedFolder //liv-ft1/Test1
< 2023-01-05 13:25:58.920 Script: Comparing...
. 2023-01-05 13:25:58.920 Collecting synchronization list for local directory 'C:\Users\User1Desktop\SychronizedFolder' and remote directory '//servername/Test1', mode = Remote, params = 0x2 (NoConfirmation), file mask = ''
* 2023-01-05 13:25:58.921 (EOSExtException) Error retrieving file list for "C:\Users\user1\Desktop\SychronizedFolder\*.*".
* 2023-01-05 13:25:58.921 System Error.  Code: 3.
* 2023-01-05 13:25:58.921 The system cannot find the path specified
. 2023-01-05 13:25:58.921 Asking user:
. 2023-01-05 13:25:58.921 Error listing directory 'C:\Users\user1\Desktop\SychronizedFolder\*.*'. ("Error retrieving file list for ""C:\Users\user1\Desktop\SychronizedFolder\*.*"".","System Error.  Code: 3.","The system cannot find the path specified")
< 2023-01-05 13:25:58.921 Script: Error listing directory 'C:\Users\user1\Desktop\SychronizedFolder\*.*'.
< 2023-01-05 13:25:58.921 Script: Error retrieving file list for "C:\Users\user1\Desktop\SychronizedFolder\*.*".
 
< 2023-01-05 13:25:58.921 System Error.  Code: 3.
 
< 2023-01-05 13:25:58.921 The system cannot find the path specified
. 2023-01-05 13:25:58.923 Answer: Abort
< 2023-01-05 13:25:58.923 Script: Error listing directory 'C:\Users\user1\Desktop\SychronizedFolder\*.*'.
< 2023-01-05 13:25:58.923 Error retrieving file list for "C:\Users\user1\Desktop\SychronizedFolder\*.*".
 
< 2023-01-05 13:25:58.923 System Error.  Code: 3.
 
< 2023-01-05 13:25:58.923 The system cannot find the path specified
. 2023-01-05 13:25:58.924 Script: Failed
. 2023-01-05 13:25:58.924 Script: Exit code: 1
. 2023-01-05 13:25:58.924 Closing connection.
. 2023-01-05 13:25:58.924 Sending special code: 1
. 2023-01-05 13:25:58.927 Main session channel closed
. 2023-01-05 13:25:58.927 All channels closed