Topic "Auto retry sync check when comparing FTP directory"

Author Message
[View user's profile]

Joined: 2017-10-03
Posts: 1
Location: South Africa
I'm running a batch file (which is being called from Task Scheduler in Windows) that calls a synchronize remote command where the destination is the FTP directory:

Batch file:

@echo off
set TRIES=7
"c:\Program Files (x86)\WinSCP\" /console /script="c:\Program Files (x86)\WinSCP\UploadScript.txt"
if %ERRORLEVEL% neq 0 (
   set /A TRIES=%TRIES%-1
   if %TRIES% gtr 1 (
       echo Failed, retrying in %INTERVAL% seconds...
       timeout /t %INTERVAL%
       goto retry
   ) else (
       echo Failed, aborting
       exit /b 1
echo Success
exit /b 0


open bupload
option batch on
synchronize remote "c:\source" "\"

Because the internet in the country is very unstable, the connection will drop for seconds at a time. And this will cause an error whilst the software is comparing the content in the file:
Local 'c:\source\2017-09-05' => Remote '\/2017-09-05'
Local 'c:\source\2017-09-06' => Remote '\/2017-09-06'
Local 'c:\source\2017-09-07' => Remote '\/2017-09-07'
Error listing directory '\/2017-09-07'.
Could not retrieve directory listing

Could not create socket.
(A)bort, (R)etry, (S)kip: Abort

As you can see it successfully receives the directory listing for the first few directories (2017-09-05 to 2017-09-06). But then it fails and automatically aborts at 2017-09-07. This happens randomly. If I run the app again it will fail at a different directory. Sometimes it doesn't even fail at all.

I would like the program to automatically try to retrieve the directory listing again if it fails because if it keeps trying it will eventually succeed (because the internet becomes stable).
My batch file has a work-around that detects if the program exits with an error and then restarts the app entirely (7 times) but this will then cause it to start comparing from the first directory again (leaving more room for connection errors to occur).

Is this possible?
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
What version of WinSCP are you using?

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License