Issue with Synchronize Command

Advertisement

JamesPowell
Joined:
Posts:
4
Location:
Colchester

Issue with Synchronize Command

Hi all, Firstly I am a bit of a noob so sorry if this is an easy solve. I have just setup a FTP server on a tablet in my warehouse and I wanted to sync the pictures to a folder on my desktop.

I tested this using the below on my own PC:-
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Users\james.QUINTA\Desktop\WinSCP.log" /ini=nul ^
/command ^
"open ftp://anonymous:anonymous%%40example.com@10.0.0.65:2221/" ^
"lcd C:\Users\james.QUINTA\Desktop\Pictures" ^
"cd /DCIM/Camera" ^
"synchronize local" ^
"exit" ^
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
 
exit /b %WINSCP_RESULT%
This works a treat and very reliable. However when I move the same to the other PC I am getting the below on the log:-
. 2022-06-23 10:17:02.234 Using FTP protocol.
. 2022-06-23 10:17:02.234 Doing startup conversation with host.
< 2022-06-23 10:17:02.235 Script: Starting the session...
> 2022-06-23 10:17:02.235 PWD
< 2022-06-23 10:17:02.239 257 "/" is current directory.
. 2022-06-23 10:17:02.239 Getting current directory name.
. 2022-06-23 10:17:02.239 Startup conversation with host finished.
< 2022-06-23 10:17:02.239 Script: Session started.
< 2022-06-23 10:17:02.240 Script: Active session: [1] anonymous@10.0.0.65
> 2022-06-23 10:17:02.241 Script: lcd C:\Users\warehouse\OneDrive\Desktop\Pictures
< 2022-06-23 10:17:02.241 Script: C:\Users\warehouse\OneDrive\Desktop\Pictures
> 2022-06-23 10:17:02.243 Script: cd /DCIM/Camera
. 2022-06-23 10:17:02.243 Changing directory to "/DCIM/Camera".
> 2022-06-23 10:17:02.243 CWD /DCIM/Camera
< 2022-06-23 10:17:02.247 250 Directory changed to /DCIM/Camera
. 2022-06-23 10:17:02.247 Getting current directory name.
> 2022-06-23 10:17:02.248 PWD
< 2022-06-23 10:17:02.251 257 "/DCIM/Camera" is current directory.
< 2022-06-23 10:17:02.251 Script: /DCIM/Camera
> 2022-06-23 10:17:02.252 Script: Sychronize local
< 2022-06-23 10:17:02.253 Script: Unknown command 'Sychronize'.
. 2022-06-23 10:17:02.253 Script: Failed
. 2022-06-23 10:17:02.253 Script: Exit code: 1
. 2022-06-23 10:17:02.260 Disconnected from server
I have tried making the S a small s but this has not affect whatsoever,

Can anybody help? Also it would be nice if this script could loop itself continuosly if anybody can post some ideas it would be appreciated.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Issue with Synchronize Command

This is not really WinSCP question. It's your batch file syntax that is wrong:
Why are some WinSCP scripting commands specified in a batch file not executed/failing?
You need to indent the wrapped lines. And the ^ after the exit line should not be there:
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Users\james.QUINTA\Desktop\WinSCP.log" /ini=nul ^
  /command ^
  "open ftp://anonymous:anonymous%%40example.com@10.0.0.65:2221/" ^
  "lcd C:\Users\james.QUINTA\Desktop\Pictures" ^
  "cd /DCIM/Camera" ^
  "synchronize local" ^
  "exit"
I have no idea how can the script work on any machine.

Reply with quote

JamesPowell
Joined:
Posts:
4
Location:
Colchester

Problem with Synchronize Command

Martin

Thanks for the help I will test this now. Also I am looking to run the script in a loop but is seems WinSCP does not support the goto function of script.

Is this the case or is there another command I could use to constantly check the remote directory and any changes immediately download to the local one?

Reply with quote

Advertisement

You can post new topics in this forum