Topic "New to scripting...and stuck!"

Author Message
floatingshed

Guest


I regularly use winscp to synchronise two ftp folders manually, always with great success.
I thought it would be nice to do this automatically, scheduled by windows task scheduler.

The manual method I use is: Log-in and have both directories on screen. From the commands menu choose Synchronize. Select "local", "mirror" and nothing ticked in comparison data (I have my reasons!). This achieves the result I want every time.

I'd be most grateful if someone could give me a partial script as a starting point, or point me in the right direction to achieve the same result.

Many thanks.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Please read documentation:
http://winscp.net/eng/docs/guide_schedule
http://winscp.net/eng/docs/guide_automation
_________________
Martin Prikryl
Guest




I have read the documentation. It simply is not clear enough.
Guest2

Guest


Anonymous wrote:
I have read the documentation. It simply is not clear enough.


I too found the documentation to be less than helpful. Check out this blog, it got be in the right direction.
http://eduboris.blogspot.com/2011/08/winscp-synchronize-scripting-example.html
Guest




OK, thanks for the pointers. I've had some success with this script:

Code:
option batch abort
option confirm off
open ftp://username@remote site
synchronize local "d:\test winscp" "/test winscp" -mirror -criteria="none"


It copies material from the remote site to the local directory but doesn't delete obsolete local files. Anyone know why not?

Thanks.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Guest2 wrote:
I too found the documentation to be less than helpful. Check out this blog, it got be in the right direction.
http://eduboris.blogspot.com/2011/08/winscp-synchronize-scripting-example.html

What does this post have that you did not find in WinSCP documentation?
_________________
Martin Prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Quote:
It copies material from the remote site to the local directory but doesn't delete obsolete local files. Anyone know why not?

You are missing -delete switch:
http://winscp.net/eng/docs/scriptcommand_synchronize
_________________
Martin Prikryl
blackmagic88
[View user's profile]

Joined: 2013-09-27
Posts: 1
prikryl wrote:
Quote:
It copies material from the remote site to the local directory but doesn't delete obsolete local files. Anyone know why not?

You are missing -delete switch:
http://winscp.net/eng/docs/scriptcommand_synchronize


I'm using version 5.1.7 but when use
Code:
synchronize remote -delete "\\Server1\LocalDirectory" "/ServerDest/RemoteDirectory" it says too many parameter for command 'synchronize'.
Can you help me with this? many thanks in advance.
Floatingshed

Guest


Thanks, got it working now.

Next problem... my ftp server has 24 directories but I only want to synchronize 20 of them. I have read the documentation and once again it is not clear, the section on masks it utterly baffling. In SIMPLE language how do I exlude certain directories?

Thanks.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Floatingshed wrote:
In SIMPLE language how do I exlude certain directories?

What did you try already? So that we can show you what did you wrong?
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License